Click here to Skip to main content
15,885,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 10-Sep-14 19:22pm
v2
Comments
Abdul Samad KP 11-Sep-14 1:27am    
I think you can use 'Attach To Process' option available under VS tools menu
RhishikeshLathe 11-Sep-14 1:41am    
can u tell, which process need to attach to which process
RhishikeshLathe 11-Sep-14 1:56am    
Thanks a lot Abdul Samad KP, now i am able to debug it...

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[^]
 
Share this answer
 
v2
Comments
RhishikeshLathe 11-Sep-14 1:58am    
Thanks a lot Raul , now i am able to debug windows service.
For this i have started my main application and while debugging attached running windows service.
Thanks a lot again.
Raul Iloc 11-Sep-14 2:00am    
Welcome, I am glad that I could help you!
Sergey Alexandrovich Kryukov 11-Sep-14 2:06am    
Agree, my 5.
But there are some other things: EventLog, and also pretty efficient approach I used; please see my answer.
—SA
Raul Iloc 11-Sep-14 3:47am    
Thank you for your feedback!
Yes, your approach is very good.
Sergey Alexandrovich Kryukov 11-Sep-14 10:48am    
Thank you, Raul.
Once, using a service-based approach, I've managed to debug 3rd-party hardware control, having no source code from that party and having never met any of their team members; we performed it all together via Internet.
—SA
Please see my past answer where I suggest different approaches: Configure Windows Service with UI[^].

—SA
 
Share this answer
 
Comments
RhishikeshLathe 11-Sep-14 2:04am    
Thanks Sergey, for suggesting different approaches.
I will consider this also.
Sergey Alexandrovich Kryukov 11-Sep-14 2:06am    
You are welcome. Will you accept it formally, too?
—SA
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900