【发布时间】:2020-03-04 12:11:48
【问题描述】:
我正在开发 Windows 服务。在catch 阻止服务停止时出现异常。
System.InvalidOperationException: 'Service AirService 没有 在电脑上找到'
InnerException- Win32Exception: 指定的服务不存在 已安装的服务。
这是我的代码
catch (Exception ex)
{
//WriteToFile("Simple Service Error on: {0} " + ex.Message + ex.StackTrace);
//Stop the Windows Service.
using (System.ServiceProcess.ServiceController serviceController = new System.ServiceProcess.ServiceController("AirService"))
{
serviceController.Stop();
}
}
如何检查服务是否安装?
【问题讨论】:
标签: c# windows windows-services