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";
}
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With