Skip to content

AssemblyVersion only contains Major version causes DLL conflicts #2887

Open
@manuelmainz

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

  1. download Newtonsoft version 13.0.1.0 somewhere locally on your machine
  2. register Newtonsoft.Json.dll in GAC by executing
    gacutil.exe /i "C:\temp\Json130r1\Bin\net45\Newtonsoft.Json.dll"
  3. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions