我在2008年VB.NET开发一个Windows服务,但我觉得我将有一个动脉瘤。要调试的服务,我已经添加了15秒的等待到初始code,这给了我时间来启动该服务,并连接.NET调试器之前什么事情发生,这样我就可以打断点和这样的。我真的很想念集成的调试这种类型的解决办法,并测试似乎是一个巨大的痛苦。
什么是做一个Windows服务在发展中的常规调试的最佳方法是什么?一个选择,我会考虑在动我所有的逻辑来一个DLL项目,只留下控制逻辑,在服务本身,然后创建一个表单的项目,基本上只是有开始和停止按钮就可以了,叫成该DLL做的一切。这样一来,我可以正常调试我的code,然后只需部署编译的服务时,DLL文件已经准备就绪。
这是否有道理/惹恼别人吗?我愿意接受任何可用的变通方法。 PB的建议here听起来像我在问什么? - 已有人用这种方法
解决方案 Debugger.Break()
:)
I'm developing a Windows Service in VB.NET 2008, but I feel like I'm going to have an aneurysm. To debug the service, I've added a 15 second wait to the initialization code, which gives me time to start the service and attach the .NET debugger before anything happens, so I can hit breakpoints and such. I really miss "integrated" debugging with this type of workaround, and testing seems to be a huge pain.
What's the best way to do "regular" debugging of a Windows Service that's in development? One option I'd considered was moving all of my logic to a DLL project, leaving only control logic in the service itself, and then creating a Forms project that essentially just had "start" and "stop" buttons on it, and called into the DLL to do everything else. This way, I can debug my code normally, and then just deploy the compiled service when the DLLs are ready.
Does this make sense/annoy others? I'm open to any workarounds available. PB's suggestion here sounds like what I'm asking - has anybody used this approach?
解决方案Debugger.Break()
:)