调试不会在限制帐户下运行的 Topshelf 服务
我有一个使用 Topshelf 编写的 Windows 服务。我正在尝试将其配置为使用具有受限权限的 Windows 帐户运行,而不是使用 LocalSystem。这也是必要的,因为我想使用集成身份验证连接到数据库。
该服务在作为 LocalSystem 运行(尽管使用包含凭据的数据库连接字符串)并作为我的有限帐户(使用 runas)运行控制台应用程序时工作。
但是,当我尝试启动服务时,服务控制管理器在等待响应时超时:
服务未及时响应启动或控制请求。
我还在应用程序弹出事件日志中收到以下内容:
应用程序错误:应用程序中位置 0x77e4bef7 处发生异常未知软件异常 (0xc06d007e)。
应用程序执行的第一件事是写入日志文件,但当我启动服务时它不会到达该文件。如果我通过控制台运行,则日志记录有效。
有什么建议我可能会错过什么或者我下一步可能会尝试什么吗?
I have a Windows service written using Topshelf. I'm trying to configure it to run using a Windows account with restricted privileges rather than using LocalSystem. That's also necessary as I'd like to connect to a database using integrated authentication.
The service works when run as LocalSystem (albeit with a database connection string containing credentials) and running the console application as my limited account (using runas) also works.
However, when I try to start the service the service control manager times out waiting for a response:
The service did not respond to the start or control request in a timely fashion.
I also get the following in the Application Popup event log:
Application Error : The exception unknown software exception (0xc06d007e) occurred in the application at location 0x77e4bef7.
The first thing that the application does is writes to a log file but it doesn't reach that when I start the service. The logging works if I run via the console.
Any suggestions what I might be missing or what I might try next?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题似乎与服务器(域控制器)有关,而不是与 TopShelf 有关。使用 .NET 服务组件构建的服务也表现出相同的行为。
该服务在不同的计算机(同一域中)上成功运行。
不幸的是,这无助于诊断问题,但给了我一个可接受的解决方法。
This problem seems to be related to the server (a domain controller) rather than TopShelf. A service built with the .NET service component also exhibits the same behaviour.
The service runs successfully on a different machine (in the same domain).
Unfortunately this doesn't help diagnose the problem but gives me an acceptable workaround.
查看 MSDN 文章调试 Windows 服务,其中介绍了如何调试 Windows 服务。
Check the MSDN article Debugging windows services which describes how you debug windows services.
我刚刚开始在一些用 .net 2.0 编写的服务中看到这一点。当服务器启动时,它们会正常启动,但如果我一整天重新启动它们,它们就不会启动,并给出此错误消息。
他们目前在一个具有管理员权限的域帐户下运行,但为了好玩,我将其切换到本地系统,并且服务正常启动。我停止了它,将其更改回域帐户(重新输入密码),并且它按预期再次正常启动。
不知道这是否算作“修复”,但这对我有用。
I've just started seeing this on a few of my services written in .net 2.0. They'll start fine when the server boots, but if I were to restart them throughout the day, they would not start, and give this error message.
They currently ran under a domain account which has admin rights on the box, but for kicks, I switched it to Local System, and the service started normally. I stopped it, changed it back to the domain account (reentering the password), and it started normally again as expected.
Don't know if this counts as a 'fix' so much, but that's what worked for me.