(JSON.NET) RuntimeBinderException accessing dynamic JObject (works on one PC, fails on another)

Viewed 1258

I use Json.net to deserialize a json string to a dynamic object:

var initialJSON = "{ 'artillery': { 'status': '0', 'code': '' }, 'diplomacy': { 'status': '0', 'code': '' }, 'seccheck': { 'status': '0', 'code': '' }, 'march': { 'status': '0', 'code': '' }, 'production': { 'status': '0', 'code': '' }, 'water': { 'status': '0', 'code': '' }, 'technology': { 'status': '0', 'code': '' }, 'spy': { 'status': '0', 'code': '' }, 'weapon': { 'status': '1', 'code': '' }, 'raid': { 'status': '0', 'code': '' }, 'prod_artillery': { 'status': '1', 'code': '' }, 'prod_bio': { 'status': '1', 'code': '' }, 'prod_nuclear': { 'status': '1', 'code': '' }, 'prod_hacking': { 'status': '1', 'code': '' }, 'prod_covops': { 'status': '1', 'code': '' }, 'prod_tank': { 'status': '1', 'code': '' }, 'prod_infantry': { 'status': '1', 'code': '' }, 'prod_fighter': { 'status': '1', 'code': '' }, 'prod_ship': { 'status': '1', 'code': '' }, 'prod_submarine': { 'status': '1', 'code': '' }, 'prod_general': { 'status': '1', 'code': '' }, 'weapon_bio': { 'status': '1', 'code': '' }, 'weapon_nuclear': { 'status': '1', 'code': '' }, 'weapon_covops': { 'status': '1', 'code': '' }, 'weapon_hacking': { 'status': '1', 'code': '' } }";
var actionData = JsonConvert.DeserializeObject<dynamic>(initialJSON);

I'm working on a team foundation server project with a colleague. After the deserialization I can access the properties like this:

actionData.production.status = "1";

But when my colleague runs the same line of code, he gets a RuntimeBinderException:

'actionData.production' threw an exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' dynamic

'Newtonsoft.Json.Linq.JObject' does not contain a definition for 'production'

While comparing we noticed that he doesn't get the "Dynamic View" on actionData:

My View:

actionData with Dynamic View

His View:

actionData without Dynamic View

How is that even possible?

We compared our Debugger/Exception Settings, they were 100% equal. Same VS Version, same project version by TFS etc.

I'm absolutely aware that I could avoid dynamic and use real objects.

But I'm extremely curious where this difference could come from.

1 Answers
Related