开发者

Debug WCF service hosted in local IIS not working

开发者 https://www.devze.com 2023-01-18 20:16 出处:网络
I have one solution WCFSampleSolution and it has all my projects - Web Service, Client and Website. The structure is something like:

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.开发者_Python百科 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!!


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.


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.


@user465876 - another approach that is less of a hassle can be found here: WCF can no longer step into a service that's locally hosted -- why not?

0

精彩评论

暂无评论...
验证码 换一张
取 消