How to enable WCF debugging in code

I have my own WCF service. I do not have the app.config file, instead, all configurations are executed at runtime. But I can't figure out how to enable debugging in code.

UPDATE

I have a VS solution with two projects:

  • WCF service hosted in a WinForms application
  • Simple console client using the service

I want to start a debugging session in Visual Studio, debug the client, set and click breakpoints in the service application. I was able to do this when I used the app.config files, but now I would like to do the same without them.

+4
source share
2 answers

Attach the debugger to the process in which your wcf service is running.

If in IIS you will need to connect to the corresponding w3p.exe process.

If in a standalone application or windows service joins the name of your exe.

In VS, the debugger option has a sub < attach to process "option. You will need to set the brak point to the appropriate code and call the service that causes this code path to execute.

May link to this link:

http://msdn.microsoft.com/en-us/library/aa702726.aspx

as well as this one:

http://www.codeproject.com/Articles/17258/Debugging-WCF-Apps

This may be useful for you.

+1
source

if you need to run the debugger from code, write the following line:

 System.Diagnostics.Debugger.Launch(); 

I often use this tecknique for debugging purposes. But it is better to remove it in the release version.

If you want to connect to an already running process, open Visual studio, go to Debug > Attach to process , find the hosting process and click the "Attach" button.

+1
source

All Articles