I have a wcf service which has to be unittested. The wcf service is hosted in a console application. In the unittest, i want the possibility to debug this wcf service. For this, the process has to be attached to the visual studio(2008 in my case) debugger.
You just have to add a reference to EnvDTE, and to add the following pice of code. With that, visual studio attaches the given process to the current debug session.
- EnvDTE.DTE dte2 = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.9.0");
- EnvDTE.Debugger debugger = dte2.Debugger;
- foreach (Process program in debugger.LocalProcesses)
- if (program.Name.Contains("MyApp.exe"))
It's handy, its easy and there is not a lot of documentation about it... There are a lot of other EnvDTE(80/90) assemblys, and i guess they are for specific visual studio versions. But i don't see the benefit in using them.