Visual Studio Developer Center > Visual Studio Forums > Visual Studio Debugger > Enabling unmanaged debugging skips all the settings of the Exception dialog
Ask a questionAsk a question
 

AnswerEnabling unmanaged debugging skips all the settings of the Exception dialog

  • Friday, November 06, 2009 12:18 PMsomos Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    When I enable the "unmanaged code debugging" suddenly the debugger breaks in all the exceptions thrown ignoring the settings of the Exception dialog. In my situation i'm trying to debug the UnmanagedException handler and with this behaviour I can not.

    Is this the expected behavior of Visual Studio?

Answers

  • Tuesday, November 10, 2009 9:51 AMRoahn LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello somos,

    Thanks for your feedback and detailed information! I think what you described is a normal situation in managed code. There are a few differences between managed, unmanaged and Mixed mode debugging, please take a look at this article for more information: http://blogs.msdn.com/stevejs/archive/2004/05/05/126497.aspx

    When debugging managed code, we usually disable unmanaged code debugging. This is because of the way different APIs work differently when we are in a debug session. It may cause conflict between threads. The detailed explain is here:
    http://blogs.msdn.com/greggm/archive/2004/01/23/62455.aspx

    Best regards,


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    • Marked As Answer bysomos Tuesday, November 10, 2009 6:37 PM
    •  

All Replies

  • Tuesday, November 10, 2009 4:35 AMRoahn LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello,

    The Exception dialog box is to enable us to capture the first-chance exceptions, while enable unmanaged code debugging enables us to debug native code (either COM components or our native code). I do not think this is the expected behavior of VS.  If we call native code (which throws exceptions) from managed code (in this situation, the native exception code will mapped to the corresponding CLR exception code and throw out as a CLR exception), then, a first chance of exception dialog box will appear. This enables us to break on the line of native code where the exception was thrown. Could you please clarify "the debugger breaks in all the exceptions thrown"? Do you mean it beaks at the same time? If you will, please post a code snippet here.

    Best regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
  • Tuesday, November 10, 2009 8:47 AMsomos Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm debugging an UnhandledException handler so I need exceptions to be thrown. I have configured VS to do not break on any exception, then I have (for example) a button set to throw new Exception() when is clicked.

    If I have unchecked the native code debugging everything works as expected and the UnhandledException  is called when I click the button, if I have it checked VS shows the dialog box asking to Break or to Continue, if I select Continue the application ends, if I select Break the application pauses as with a breakpoint, if I hit Run to continue the same dialog is shown again with the same behaviour.

    Hope this clarifies the question.
  • Tuesday, November 10, 2009 9:51 AMRoahn LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello somos,

    Thanks for your feedback and detailed information! I think what you described is a normal situation in managed code. There are a few differences between managed, unmanaged and Mixed mode debugging, please take a look at this article for more information: http://blogs.msdn.com/stevejs/archive/2004/05/05/126497.aspx

    When debugging managed code, we usually disable unmanaged code debugging. This is because of the way different APIs work differently when we are in a debug session. It may cause conflict between threads. The detailed explain is here:
    http://blogs.msdn.com/greggm/archive/2004/01/23/62455.aspx

    Best regards,


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    • Marked As Answer bysomos Tuesday, November 10, 2009 6:37 PM
    •  
  • Tuesday, November 10, 2009 6:37 PMsomos Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks a lot Roahn, those articles has been of a lot of help!