C# ServiceInstaller。卸载不会停止Windows 10上的服务

C# ServiceInstaller。卸载不会停止Windows 10上的服务,c#,windows,windows-services,C#,Windows,Windows Services,有一种奇怪的行为 我有以下代码: ServiceInstaller serviceInstaller = new ServiceInstaller(); InstallContext installContext = new InstallContext(); serviceInstaller.Context = installContext; serviceInstaller.ServiceName = strServiceName; serviceInstaller.Uninstall(nu

有一种奇怪的行为

我有以下代码:

ServiceInstaller serviceInstaller = new ServiceInstaller();
InstallContext installContext = new InstallContext();
serviceInstaller.Context = installContext;
serviceInstaller.ServiceName = strServiceName;
serviceInstaller.Uninstall(null);
在Windows7上一切正常,但在Windows10上不起作用

我必须明确停止服务(通过
ServiceController.stop()
),才能在Windows 10上卸载它

如MSDN中所述,
ServiceInstaller.Uninstall()
尝试停止服务,但如果停止失败,则继续工作,没有任何异常

卸载首先尝试在卸载服务之前停止服务。 如果无法停止服务,则不会捕获异常,并且 方法继续删除服务


在Windows7和Windows10中停止线程有什么区别吗?或者可能
ServiceInstaller.Uninstall()
没有尝试停止Windows 10上的服务?

此问题可能与Creator Update有关。我曾尝试在Windows 10上执行我的程序,但没有新的创建者更新,效果很好……这个问题可能与创建者更新有关。我曾尝试在Windows 10上执行我的程序,但没有新的创建者更新,而且效果很好。。。