Debugging a WCF Service
Following are the 3-different ways to start debugging a WCF service:
Debugging with Visual Studio 2008
Using Visual Studio 2008, one can step into a WCF service. One can hit break points inside the WCF service, if the WCF service is in the same solution as the client.
For stepping to work, you must have debugging enabled in the app.config or Web.config file we will discuss later on the limitation and how to enable debugging.
To step into a WCF Service
Limitations of Debugging a WCF Service
1.Stepping Into a Service
The following conditions should be met when you start To step into a service from a client applications:
2.Stepping Out of a Service
The limitations are the same as described the above, in addition, here the debugger must be attached to the client.
This is because while you are debugging a client and step into a service, the debugger remains attached to the service whether you started the client by using Start Debugging or attached to the client by using Attach to Process.
But while you are debugging by attaching to the service, the debugger is not yet attached to the client. In that case, you must first use Attach to Process to attach to the client manually.
Debugging must be enabled
3.Automatic Attach to a Service
Automatically attaching to a service has the following limitations:
Enabling Debugging a WCF Service
Use following piece of lines in web.config or asp.config file(s):
<compilation debug="true" />
Note: In case when you use Attach to Process on a service, the debug code is automatically added to the .config file.
How to Debug a Self-Hosted WCF Service?
In simple words WCF service which does not run inside IIS, WCF service Host or ASP.NET Development Server is know as Self-Hosted Service.
To debug such services we need to configure Visual Studio to launch both client and server when you choose Start Debugging on the Debug menu.
How to start both client and host from Visual Studio?
a. From Solution Explorer, right-click the solution name.
b. Click Set Startup Projects.
c. In Solution from
d. Click Action and choose Start from the Multiple Startup Projects grid,
on the line that corresponds to the server project also on the line that
corresponds to the client project, click Action and choose Start.
e. Finally click OK.
Gaurav is a Microsoft Technology Specialist professional. He has awarded lifetime membership from Computer Society of India (CSI). He has more than 13yrs of experience in the industry. Currently, he is working in the capacity of Solution Architect with an MNC. He is serving to the various communities since 1999.
Follow Gaurav Aroraa or read 149 articles authored by Gaurav Aroraa