Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred

When using dynamic on Newtonsoft JObjects, I get a lot of Microsoft.CSharp.RuntimeBinder.RuntimeBinderException in my debug output. Although the exceptions must be trapped somewhere in Microsoft.CSharp.dll, it makes me vaguely uncomfortable that they are occurring. Is there anything I can do to stop them (other than forgoing dynamic altogether)?

Here is a short test program which outputs one of these exceptions:

    using System;
    using Newtonsoft.Json.Linq;

    namespace DynamicTest {
        class Program {
            static void Main(string[] args) {
                JObject j = new JObject();
                j["DocumentName"] = "Name";
                dynamic d = j;
                d.DocumentName = "Changed";
            }
        }
    }
like image 510
Nikki Locke Avatar asked May 07 '15 15:05

Nikki Locke


1 Answers

The creator of JSON.Net himself addressed it here

Assuring that it's something minor and the exception is by design. More information on RuntimeBinderException has already been answered here on StackOverflow

By the way if you wish to disable these warnings just coz they make you uncomfortable.

In Visual Studio click on Tools - > Options and then select Debugging and Check the box that says Enable Just My Code.

like image 59
Nathan Avatar answered Nov 12 '22 12:11

Nathan