Description
Environment
I am using Nuget package 13.0.3 and my application has target framework net48.
On a customer machine any other tool has registered an older version (probably 13.0.1) of Newtonsoft.Json in GAC (Global Assembly Cache).
Both versions of Newtonsoft have Assembly version 13.0.0.0.
Even though our application does not register Newtonsoft in GAC, we still break because another application, which is out of our control, (not really sure which one it is) and installed on client machine registers in GAC.
So you get the complains by the customer, even though it is not even your fault.
In my opinion the Assembly version should always contain the Major and Release version number. In this way the application is able to determine if there is the same version in GAC or not.
Source code
var a = new JsonSerializerSettings();
a.Formatting = Formatting.Indented;
var b = new JsonSerializerSettings(a);
Expected behavior
The assembly Newtonsoft v 13.0.3.0 out of my binary directory should get loaded.
Actual behavior
The assembly gets loaded from GAC and causes following exception to be thrown, because this constructor has been introduced with version 13.0.2.
System.MissingMethodException: 'Method not found: 'Void Newtonsoft.Json.JsonSerializerSettings..ctor(Newtonsoft.Json.JsonSerializerSettings)'.'
Steps to reproduce
- download Newtonsoft version 13.0.1.0 somewhere locally on your machine
- register Newtonsoft.Json.dll in GAC by executing
gacutil.exe /i "C:\temp\Json130r1\Bin\net45\Newtonsoft.Json.dll"
- Run your application which contains above C# code including the copy constructor.
For reference to cleanup your local machine again:
To unregister the assembly from GAC run gacutil.exe /u Newtonsoft.Json
Activity