I am currently trying to launch a debugger for a process that is launched externally (not from within visual studio). I cannot seem to get a debugger actually launch, as it appears nothing happens. In the 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 asserts are there to verify that I'm not crazy. At first, the IsAttached property returns false as I expect. I then call Debugger.Launch, and that returns true. As per the MSDN documentation of Debugger.Launch, it says it will only return true if it succeeds in launching the debugger, or if one is already attached. I verified one was not attached, so it must have launched one.
The break-point never gets hit, and the second verify fails (the IsAttached property returns false). I also attempted to put a sleep in after Debugger.Launch to give it some time, to no avail.
Any suggestions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…