'JSON to dynamic - 'Newtonsoft.Json.Linq.JObject' does not contain a definition

I am using MVC WebAPI and passing in JSON object to a method that has parameter defined as dynamic. When using the method I am accessing the property of the dynamic object. It throws me this error - 'Newtonsoft.Json.Linq.JObject' does not contain a definition'

private dynamic Method1([FromBody]dynamic obj)
{
  if (obj.Name.Value == "Hello")
  {
   //Code
  }
}

JSON has right Key-Value pair.

This code works fine on other machine but throws error on one. Just wondering if there is something wrong with my installation or I am missing something ?



Solution 1:[1]

I had a similar problem with an app that used Json.NET as a private assembly. The issue ocurred only on a specific machine and it turned out that the machine had another version of Json.NET installed in GAC. After removing it from GAC the app started to work correctly.

Solution 2:[2]

The creator of JSON.Net himself addressed it here

Assuring that it's something minor and the exception is by design.

By the way if you wish to disable these warnings just because 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.

More Info Stackoverflow

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Aravindhan R