Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug WCF programs

Tags:

My code uses lots of WCF calls and when I try to debug it, it doesnt go to the service code itself. Is there a way to debug WCF code somehow?

like image 505
Val Avatar asked Jan 06 '12 02:01

Val


People also ask

How do you debug a WCF Test client?

WCF Service Host Starts WCF Test Client with a Single Service. After you create a new WCF service project and press F5 to start the debugger, the WCF Service Host begins to host the service in your project. Then, WCF Test Client opens and displays a list of service endpoints defined in the configuration file.

How do I debug IIS hosted WCF service?

The easiest way to debug a self-hosted WCF is to configure Visual Studio to launch both client and server when you choose Start Debugging on the Debug menu. If the WCF service is self-hosting inside or a process that cannot be launched in this manner, such as NT service, you cannot use this method.

How do I debug SVC?

Visual Studio provides you a test client to run and debug the service. To use this test client, select your service in Solution Explorer ( CustomerProfile. svc ) and, from the Debug menu, select Start Debugging (or just press F5). Visual Studio will run the code in debug mode using the WCF Test Client, as shown in ...


2 Answers

There's a much easier way. Just start multiple processes in Visual Studio. Right click the Solution. Click Properties. Select Startup Project. Click Multiple Startup Projects. Set the WCF and the Client projects to Action=Start. Now you will step through the WCF as well as the client.

like image 90
Nigel Shaw Avatar answered Sep 22 '22 02:09

Nigel Shaw


You need to attach the debugger to the process that your wcf service is running in.

If in iis you need to attach to the corresponding w3p.exe process.

If in a stand alone app or windows service, attach to the name of your exe.

In Visual Studio, on the debugger menu, there is an "attach to process". Open the relevant code, set a breakpoint, and call the service causing that code path to execute.

Outside of debugging, using .net tracing with switchable levels is a good way to get insight to what's going on. I typically setup sys internals debugview to color highlight errors and warnings and constantly have it running while running code or tests. Colored lines out of my peripheral vision while working finds issues.

like image 23
bryanmac Avatar answered Sep 20 '22 02:09

bryanmac