最简单的开发/调试Windows服务的方法 [英] Easiest way to develop/debug a Windows service

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

问题描述

我正在VB.NET 2008中开发一个Windows服务,但我觉得我会有一个动脉瘤。要调试服务,我已经添加了15秒钟的初始化代码,这让我有时间启动服务,并在任何事情发生之前附加.NET调试器,所以我可以打破断点等。我真的想错过这种类型的解决方案的集成调试,测试似乎是一个巨大的痛苦。



什么是最好的方式做一个Windows的常规调试正在开发的服务我考虑过的一个选择是将我的所有逻辑转移到一个DLL项目中,仅在服务本身中保留控制逻辑,然后创建一个基本上只有开始和停止按钮的Forms项目,并调用该DLL做其他事情。这样,我可以正常调试我的代码,然后在DLL准备就绪时部署编译的服务。



这是否有意义?我可以使用任何可用的解决方法。 PB的建议这里听起来像我'请问 - 有人使用这种方法吗?

解决方案

  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服务的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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