Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugger.Launch not working

Tags:

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?

like image 858
Trevor Sundberg Avatar asked Sep 29 '12 19:09

Trevor Sundberg


People also ask

How do I know if debugger is attached?

Kernel-mode code can determine the status of kernel debugging by using the following variables and routines: The KD_DEBUGGER_ENABLED global kernel variable indicates whether kernel debugging is enabled. The KD_DEBUGGER_NOT_PRESENT global kernel variable indicates whether a kernel debugger is currently attached.

How do I enable debugging in Visual Studio?

In the Visual Studio toolbar, make sure the configuration is set to Debug. To start debugging, select the profile name in the toolbar, such as <project profile name>, IIS Express, or <IIS profile name> in the toolbar, select Start Debugging from the Debug menu, or press F5.

What is debug assert C#?

Assert(Boolean, Debug+AssertInterpolatedStringHandler) Checks for a condition; if the condition is false , outputs a specified message and displays a message box that shows the call stack. public: static void Assert(bool condition, System::Diagnostics::Debug::AssertInterpolatedStringHandler % message); C# Copy.


2 Answers

I have the same problem in Visual Studio 2013 Premium. Eric's answer put me over how to resolve it. But you don't need to change the register.

  1. Go to Tools --> Options --> Debugging
  2. Open the item and select just in time debugger
  3. If you see in the low part of the window a yellow warning about that other debug is being used different to Visual Studio. If you see that, check all Just in Time checkboxes to return to VS to be the debug program.

That is all!

Options Just in Time debugger

like image 131
freedeveloper Avatar answered Dec 07 '22 14:12

freedeveloper


That is a lame answer, since I can't find any reference to VS Express in the question and I had the same problem while using VS2013 Pro.

Even though this article sais the issue is solved in VS2013, even if you are using VS2013 like me, look for the temporary fixes tab listed there. I fixed the issue using it. More info in the link.

I'll just link another article which put me in the right direction, perhaps it's useful too.

Summary: Change the AppIDFlags value of the Visual Studio Just-In-Time Debugger registry key from 0x28 to 0x8 (or 0x20 according to the article above, trial and error I guess) They registry key is HKEY_CLASSES_ROOT\AppID\{E62A7A31-6025-408E-87F6-81AEB0DC9347}

like image 33
Eric Avatar answered Dec 07 '22 15:12

Eric