开发者

Visual Studio 2010 debugger not doing anything for WCF project

I have a WCF web service (using .NET 3.5) that I am trying to debug. However, whenever I set any breakpoints in the program, they 开发者_如何学编程are never hit when running in debug mode. Also, no exceptions are caught by Visual Studio--normally, when an uncaught exception is thrown while debugging, Visual Studio will show the exception being thrown and take you to the line of code where the exception was thrown.

Can anyone shed some light on this issue?


Are you perhaps trying to remotely debug the service? In that case you need to run the VS Remote Debugger on the remote computer as well.

Also you should set the Service Debug Behavior in your code to get exception details, like this:

ServiceHost MyServiceHost = new ServiceHost(myService, myBaseAddress);

#if CONFIG = "Debug"
//set Service Debug Behavior (for security should not be enabled during deployment)
Description.ServiceDebugBehavior sdb = MyServiceHost.Description.Behaviors.Find<Description.ServiceDebugBehavior>();
if (sdb == null) {
sdb = new Description.ServiceDebugBehavior();
MyServiceHost.Description.Behaviors.Add(sdb);
}
sdb.IncludeExceptionDetailInFaults = true;
#endif

MyServiceHost.AddServiceEndpoint(typeof(IMyService), new NetTcpBinding(), myBaseAddress);
MyServiceHost.Open();


I'm very late with this answer, but maybe it will help someone else. You can experience this problem when you are debugging a web service that uses the local IIS instead of the Visual Studio dev server.

In this case, you must attach to the running instance of IIS, not just hit "Run". To do this, click on Debug=>Attach To Process. Then, select the Process, "w3wp.exe". Finally, select "Attach" and you should be all set.

Visual Studio 2010 debugger not doing anything for WCF project

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜