【发布时间】:2023-03-14 20:33:02
【问题描述】:
我正在尝试使用 nssm 服务管理器运行我的 wpf 服务。问题是使用 nssm 我可以安装服务,但是当我尝试启动它时,我在终端中得到以下响应:
MyService:响应 START 控制的意外状态 SERVICE_PAUSED。
然后在 EventViewer 中出现以下错误:
服务无法启动。服务进程无法连接到服务控制器
虽然我可以使用 NET 命令或使用 VisualStudio 来启动我的服务,但这个问题只发生在 nssm 中...
框架: .NET Framework 4.6.1
关于如何解决此问题的任何建议?
编辑 1
我使用https://docs.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer 示例创建了示例 WPF 服务。结果还是一样。
编辑 2
我设法得到 NSSM 错误:
Cannot start service from the command line or a debugger. A Windows Service must first be installed (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative tool or the NET START command.
我现在不明白 nssm 是如何工作的......
【问题讨论】:
-
您能分享您的服务代码吗?另外,您使用的是哪个 .NET 版本?
-
@PavelAnikhouski 抱歉我不能分享代码
-
@PavelAnikhouski 框架添加到问题
-
那么,问题是
installutil.exe可以成功安装并运行你的服务,但是nssm不能运行?你能分享模式细节吗,比如日志或错误代码。由于您没有共享代码,因此很难找出问题 -
是的,我可以使用 instlalutil.exe 和 Visual Sudio 运行我的服务。没有错误代码。 EventViewer 显示错误和警告。错误:MyService:响应 START 控制的意外状态 SERVICE_PAUSED。警告:Service MyService 运行时间少于 1500 毫秒。重启会延迟 4000 毫秒。