Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug WCF service hosted in local IIS not working

I have one solution WCFSampleSolution and it has all my projects - Web Service, Client and Website. The structure is something like:

  • WCFSampleSolution
    • C:\WCFSample\Website
    • WCFService
    • WCFWebClient

I created WCFService project for my services. It contains IService1.cs and Service1.cs. Then I hosted the service in IIS. I did this by creating a website and adding .svc and web.config files to the website project. Then published it in IIS. When I run http:\MyMachineName\Website\Service.svc, it shows the service description. Then I create the web client that calls the webservice. I used the service reference to add the service. It calls a method of Service1. It works fine. But I amnot able to debug this program/setup. I verified the config files in WCFWebClient project and Website project and they have proper debug settings.

<compilation debug="true">

I put break points but control never goes to my seb service. I also tried attach process, but it also doesn't work. But I was able to debug one of my other WCF projects. The setup was little different. In that project I copied the .svc file and config in my web client and the debug works fine.

Please HELP!!

like image 468
Sri Reddy Avatar asked Oct 06 '10 19:10

Sri Reddy


People also ask

How do I debug locally in IIS?

To start debugging, select IIS Express (<Browser name>) or Local IIS (<Browser name>) in the toolbar, select Start Debugging from the Debug menu, or press F5. The debugger pauses at the breakpoints. If the debugger can't hit the breakpoints, see Troubleshoot debugging.

How do I debug a WCF service?

To debug a WCF service in visual studio 2010, go to Debug -> Attach to Process. Check "Show processes from all users", and choose w3p.exe if you are using IIS, or the name of the application if not. Put in a breakpoint, make the call, and then you can then start debugging.


2 Answers

You are hosting your service on IIS so I am sure you must be attaching to w3wp.exe process. While trying to attach if VS built in web server is starting, then attach to that process as well.

like image 195
Pradeep Avatar answered Sep 19 '22 06:09

Pradeep


What I find particularly easy is having two instances of visual studio open (especially if you use NUnit or doing anything to test out code). One will attach NUnit or whatever you wish, and the other will attach the w3wp.exe process. The easiest way is to:

1) Put a break point in the 1st instance of visual studio of the code right before it will hit the WCF service hosted on your machine.

2) Once the code stops at your breakpoint, set breakpoints in the 2nd instance of visual studio where you want to break then attach the w3wp.exe process.

3) Once you continue, the breakpoint on the service code should be hit.

It is sometimes easier to find the process id as well when attaching w3wp.exe. Using IIS, you can go to "Worker Process" and find the process id to attach for your Application Pool Name.

like image 44
5StringRyan Avatar answered Sep 22 '22 06:09

5StringRyan