Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssemblyVersion only contains Major version causes DLL conflicts #2887

Open
manuelmainz opened this issue Aug 22, 2023 · 4 comments · May be fixed by #2976
Open

AssemblyVersion only contains Major version causes DLL conflicts #2887

manuelmainz opened this issue Aug 22, 2023 · 4 comments · May be fixed by #2976

Comments

@manuelmainz
Copy link

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

manuelmainz pushed a commit to manuelmainz/Newtonsoft.Json that referenced this issue Aug 22, 2023
…sion to avoid version mismatch with dlls in GAC
@readyjoseph
Copy link

readyjoseph commented Feb 8, 2024

We are having similar issue. The azure build pipeline artefact throws
"Could not load file or assembly 'Newtonsoft.Json, Version=13.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
But locally published artefact works without issue.
The newtonsoft version in both packages is the same. So, I am lost what could be the cause of this issue.

EDIT: I downgraded from 13.0.3 to 13.0.1, but this has a bizarre affect. It works in couple of places and fails in another with the same issue.

NOTE: Again - it works fine if I publish it locally and apply it. But the behavior observed when using package from Azure pipeline. Is this an issue with Azure vms?

@JustinSchneiderPBI
Copy link

Several other examples of the issue popping up. https://developercommunity.visualstudio.com/t/cannot-sign-in-to-visual-studio/105291
https://www.telerik.com/forums/newtonsoft-json-dll-is-installed-in-the-gac
https://forum.devolutions.net/topics/24268/newtonsoft-json-in-gac
And we have customers reporting this issue to us for Power BI Desktop as well. Please address this years-old issue.

@JustinSchneiderPBI
Copy link

Here's a PR attempting to make the stated adjustment: #2976. It needs a test and the change + fix need to be verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants