最简单的开发/调试Windows服务在.NET的方式 [英] Easiest way to develop/debug a Windows Service in .NET

查看:320
本文介绍了最简单的开发/调试Windows服务在.NET的方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在2008年VB.NET开发一个Windows服务,但我觉得我将有一个动脉瘤。要调试的服务,我已经添加了15秒的等待到初始code,这给了我时间来启动该服务,并连接.NET调试器之前什么事情发生,这样我就可以打断点和这样的。我真的很想念集成的调试这种类型的解决办法,并测试似乎是一个巨大的痛苦。

什么是做一个Windows服务在发展中的常规调试的最佳方法是什么?一个选择,我会考虑在动我所有的逻辑来一个DLL项目,只留下控制逻辑,在服务本身,然后创建一个表单的项目,基本上只是有开始和停止按钮就可以了,叫成该DLL做的一切。这样一来,我可以正常调试我的code,然后只需部署编译的服务时,DLL文件已经准备就绪。

这是否有道理/惹恼别人吗?我愿意接受任何可用的变通方法。 PB的建议<一href="http://stackoverflow.com/questions/125964/easier-way-to-start-debugging-a-windows-service-in-c">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()

:)

这篇关于最简单的开发/调试Windows服务在.NET的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆