-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Open
Description
Applications compiled against Newtonsoft.Json 13.0.4 can fail at runtime if version 13.0.3 is installed in the Global Assembly Cache (GAC).
Because both 13.0.3 and 13.0.4 use AssemblyVersion = 13.0.0.0, the CLR will load the 13.0.3 assembly from the GAC even when the application was compiled against 13.0.4. This results in missing members at runtime.
Steps to Reproduce
- Install Newtonsoft.Json 13.0.3 into the GAC:
gacutil /i Newtonsoft.Json.dll (13.0.3)
- Create a project that references NuGet package Newtonsoft.Json 13.0.4.
- Use the following code:
using Newtonsoft.Json; using Newtonsoft.Json.Linq; var jObject = JObject.Parse("{'fieldName':{'fieldValue':'innerObjectValue'},'anotherField':'anotherValue'}"); jObject.ToString(Formatting.None);
- Build and run the project on the machine with 13.0.3 in the GAC.
Expected Behavior
The application should load the version it was compiled against (13.0.4) and successfully invoke the ToString overload.
Actual Behavior
The runtime loads Newtonsoft.Json 13.0.3 from the GAC, and the following exception occurs:
System.MissingMethodException : Method not found:
'System.String Newtonsoft.Json.Linq.JToken.ToString(Newtonsoft.Json.Formatting)'
Notes
- The issue is triggered by the fact that the
AssemblyVersionremains13.0.0.0across these patch releases. - Since the GAC version takes precedence, applications compiled against 13.0.4 cannot safely run when 13.0.3 is present in the GAC.
ahoke-cr, amylnikov2, mjwires, HamsterExAstris, FollowerOJ and 3 more
Metadata
Metadata
Assignees
Labels
No labels