Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress RuntimeBinderException messages from dynamic types

I've recently started using a private NuGet server to manage my organization's internal libraries. This means in order to step into our own code that is in a library, I need to disable "Enable Just My Code" in debugging options since we aren't referring to the projects directly any more. This is a pretty hefty MVC project that uses dynamic types and ExpandoObjects in addition to ViewBag. I get two RuntimeBinderExceptions for every single use of a dynamic type... which is a lot. This appears to be normal behavior from what I've read. Normal it may be, but useful it is not.

My first thought was to disable this particular exeption in the Debug-> Exceptions dialog. The exception is not to be found there. I can't figure out any way to be able to step outside the projects referenced directly, without also opening myself up to these exceptions. (And all manner of other low-level framework exceptions that I don't want to hear about, but this is the biggest offender by far).

What's the best way to deal with this?

Edit: This is the problem. How do I stop this with "Enable Just My Code" disabled?

enter image description here

like image 387
Jamie Treworgy Avatar asked Jul 11 '12 18:07

Jamie Treworgy


1 Answers

You can add additional "exception" names (existing in your own code or other libraries)...so long as you know the exception's fully qualified type name.

Managing Exception with the Debugger
https://msdn.microsoft.com/en-us/library/x85tt0dd.aspx

In Visual Studio 2010

Via the Debug | Exceptions... dialog.

enter image description here

  • Use the Add button to add a new exception under the Common Language Runtime Exceptions group and call it Microsoft.CSharp.RuntimeBinder.RuntimeBinderException

enter image description here

  • then just make sure Thrown and User-Handled are NOT ticked - thus causing the first chance exception to be ignored, rather than being caught by the debugger.

In Visual Studio 2017

Via the Debug | Windows | Exception Settings... panel

enter image description here

enter image description here

  • Use + to add the new exception name

enter image description here

  • make sure it's unticked
like image 112
CSmith Avatar answered Nov 09 '22 01:11

CSmith