C# Windows 服务意外终止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1211870/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows Service terminated unexpectedly
提问by JD.
I have a windows service which has a number of threads that do some work. All has been going well in testing, until once, where I saw "windows service terminated unexpectedly" in the event viewer.
我有一个 Windows 服务,它有许多线程可以做一些工作。在测试中一切都进展顺利,直到有一次,我在事件查看器中看到“Windows 服务意外终止”。
How do I go about trying to debug where this is happening? I have exceptions being caught under normal circumstances but not in this case.
我该如何去尝试调试发生这种情况的地方?我在正常情况下有异常被捕获,但在这种情况下不会。
I do not know where to start.
我不知道从哪里开始。
JD.
法学博士。
采纳答案by Matt Davis
Put a call to System.Diagnostics.Debugger.Break() in your OnStart() callback. When your service starts up, you'll be prompted to start the Visual Studio debugger. Once the debugger opens, you can debug from there.
在 OnStart() 回调中调用 System.Diagnostics.Debugger.Break()。当您的服务启动时,系统会提示您启动 Visual Studio 调试器。调试器打开后,您可以从那里进行调试。
回答by Arsen Mkrtchyan
here you can find How to: Debug Windows Service Applications
在这里您可以找到如何:调试 Windows 服务应用程序