DebuggerNonUserCodeAttribute Saves The Day

July 14 2011

Sometimes Visual Studio is too smart. Hit a situation yesterday where I has a solution with an .exe and a .dll. In the .dll, there's a method called by the .exe that throws an exception.  I needed to test the logic of how the .exe handled that exception. But, while debugging, the project would always break on the throw in the .dll and I couldn't ever get it to continue on to test my logic in the .exe. 

Finally, I got it to bypass the class in the .dll by attibuting the class dll with the DebuggerNonUserCodeAttribute.  Walla! Now I could check the logic in the .exe when the exception was thrown.

Comments (2) -

7/14/2011 3:01:10 PM #

Caleb Vear

You can disable Visual Studios break on exceptions behaviour by pressing Control+Alt+E (or navigate to Debug > Exceptions...) and uncheck the "Thrown" column for the Common Language Runtime item.  Most of the time I like breaking imediately when the exception is thrown, but sometimes such as the situation you found yourself in you don't want that behaviour.

Caleb Vear

7/15/2011 8:45:50 AM #

Karsten Januszewski

Thanks Caleb!  I totally forgot about that menu and was searching desperately for it and couldn't find it, which is why I resorted to the solution I explained in the blog post. Thanks for reminding me about the Debug Exceptions menu.

Karsten Januszewski

8/16/2011 3:32:44 PM #

Путаны Москвы

Sometimes Visual Studio is too smart.  Hit a situation yesterday where I has a solution with an . exe and a .

Путаны Москвы

Add comment

Enter your name, handle, alias, or email.

We'll incarnate your avatar from the services below.



biuquote
Loading