如何调试使用ServiceBase类创建的Windows服务 [英] How to Debug the windows service created using ServiceBase class

查看:268
本文介绍了如何调试使用ServiceBase类创建的Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的解决方案包含两个项目,WPF主应用程序项目和Windows服务项目(通过继承ServiceBase类使用控制台应用程序创建)。当我构建Windows服务项目时,它为windows服务创建exe文件,这个exe安装在services.msc中。主WPF应用程序项目使用端点和代理使用此安装的服务。



我的问题是:我不知道如何调试这样的服务。谁能告诉我如何调试这些服务。

请帮助。

Hi,
I have solution that contains two projects, WPF main application project and windows service project(created using console application by inheriting ServiceBase class). When i build windows service project it creates exe file for windows service this exe is installed in services.msc. The main WPF application project is using this installed service using endpoints and proxy.

My problem is: i didn't know how to debug such service. Can anyone please tell me how to debug such services.
Please help.

推荐答案

1.第一个解决方案,与调试有关任何Widnows服务应用程序,都是将您的项目从Visual Studio附加到已安装的进程。你可以在这里看到详细信息:

http:/ /msdn.microsoft.com/en-us/library/7a50syb3(v=vs.110).aspx [ ^ ]



2.因为事实上你想要测试您的WCF服务而不是Windows服务本身,您应该创建一个类型为 WCF服务库的新项目,然后您必须将所有WCF服务部分移入其中在您的Windows服务项目中,包括app.config中的设置。



在现有的Windows服务中,您必须保留app.config中的所有WCF设置(因此您将在2个位置保留它们),以及WCF的托管部分服务本身(使用 ServiceHost 类)。



然后你可以直接从Visual测试你的WCF服务Studio,当您在调试模式下启动用户界面应用程序时,VS将自动启动并将您的WCF服务托管到WCF测试客户端中。您应该阅读下一个有关WCF测试客户端的详细信息 [ ^ ]
1.The first solution, related wit the debugging of any Widnows Service aaplication, is to attach your project from Visual Studio to the to the installed process. You can see details here:
http://msdn.microsoft.com/en-us/library/7a50syb3(v=vs.110).aspx[^]

2. Because in fact you want to test your WCF service and not the Windows service itself, you should create a new project of type WCF Service Library then you have to move into it all WCF Service part existing now in your Windows service project, including the settings from app.config.

In your existing Windows Service you have to keep all WCF settings from app.config (so you will have them in 2 places), and the hosting part of the WCF service itself (the usage of ServiceHost class).

Then you will can test your WCF service directly from Visual Studio, when you start your user interface application in Debug mode, automatically the VS will start and host your WCF service into the "WCF Test Client". You should read the next details about WCF Test Client[^]


请参阅我过去的答案,我建议采用不同的方法:使用UI配置Windows服务 [ ^ ]。



-SA
Please see my past answer where I suggest different approaches: Configure Windows Service with UI[^].

—SA


这可以你是这样的。 如何在不安装的情况下调试或测试Windows服务。 .. [ ^ ]



您可以在Google上找到大量相关文章。试一试。
This could be you way. How to Debug or Test your Windows Service Without Installing it...[^]

A part from that you can find tons of related Article on Google. Just give it a try.


这篇关于如何调试使用ServiceBase类创建的Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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