I am currently trying to run a debugger for a process that is being launched externally (not from visual studio). It seems I canβt actually start the debugger, as it seems like nothing is happening. In this process, I added this code:
Debug.Assert(Debugger.IsAttached == false, "Should be no debugger");
if (!Debugger.IsAttached)
{
Debug.Assert(Debugger.Launch(), "Debugger not launched");
}
Debugger.Break();
Debug.Assert(Debugger.IsAttached == true, "Debugger should be attached");
The allegations are there to make sure I'm not crazy. The IsAttached property first returns false, as I expect. Then I call Debugger.Launch and returns true . According to the MSDN documentation for Debugger.Launch, he says that he will return true only if he manages to start the debugger or if it is already connected. I confirmed that one of them was not attached, so he had to start it.
A breakpoint never hits, and the second check fails (the IsAttached property returns false). I also tried falling asleep after Debugger.Launch to give it some time, to no avail.
Any suggestions?
source
share