我开发了一个窗口应用程序,还创建了一项服务。我在窗口应用程序中使用编码启动服务,但出现无法在计算机上打开窗口服务的错误 '.'
我使用了下面的代码。
ServiceController controller = new ServiceController("SeoMozScheduleService");
if (controller.Status == ServiceControllerStatus.Stopped)
{
controller.Start();
}
如果我右键单击“应用程序”并单击“以管理员身份运行”,它对我来说工作正常...
最佳答案
要在每次打开应用程序时自动执行此操作,您必须 add a manifest file到您的解决方案,然后将文件中的 requestedExecutionLevel
节点更新为如下所示:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
但是,如果启用了 UAC,更改此设置将导致系统每次都提示您以管理员身份运行应用程序。
关于c# - 无法在窗口应用程序中打开计算机 '.' 上的窗口服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14501748/