sc.Pause()抛出异常

问题描述 投票:0回答:1
            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

vb.net try-catch servicecontroller
1个回答
0
投票

我想出了一块拼图。我更改了app.manifest文件以运行

highestAvailable

现在它抛出一个例外

'Cannot pause Dhcp service on computer '.' Inner Exception Win32Exception: The request control is not valid for this service
© www.soinside.com 2019 - 2024. All rights reserved.