sc.Pause()引发异常

时间:2019-04-02 13:53:41

标签: vb.net try-catch servicecontroller

            sc.Pause()
            Try
                While sc.Status = ServiceControllerStatus.Paused
                    Threading.Thread.Sleep(1000)
                    sc.Refresh()
                End While
            Catch ex As Exception

            End Try

大家好!

我上面的代码有问题。当sc.Pause()运行时,它给了我

的例外
'Cannot open Dhcp Service on computer '.' inner Exception Win32Exception: Access is denied

感谢您的帮助!

谢谢

Kyvex

1 个答案:

答案 0 :(得分:0)

我想出了一个难题。我将app.manifest文件更改为在其中运行

highestAvailable

现在它引发了一个异常

'Cannot pause Dhcp service on computer '.' Inner Exception Win32Exception: The request control is not valid for this service