When using dynamic in Newtonsoft JObjects, I get a lot Microsoft.CSharp.RuntimeBinder.RuntimeBinderExceptionin my debug output. Although the trap exceptions are somewhere in Microsoft.CSharp.dll, it makes me uncomfortable that they happen. Is there anything I can do to stop them (different from giving up dynamics altogether)?
Here is a brief test program that throws 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";
}
}
}
source
share