We've recently updated Newtonsoft.JSON and another Nuget package, SKGLExtension, across both our WPF and Excel add-in products.
All of our referenced projects use the Newtonsoft.JSON.dll version 11.0.0 nuget package.
Both the WPF and Excel products reference an engine .dll, which then reference the SKGLExtension which uses Newtonsoft.JSON.dll.
When the Excel add-in is installed via MSI and run, we get this binding error:
System.IO.FileLoadException: 'Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.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)'
=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Foo/Bar/
LOG: Initial PrivatePath = NULL
Calling assembly : SKM, Version=4.0.3.1, Culture=neutral, PublicKeyToken=30182975912ff1ef.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Foo/Bar/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
From this line of code in our engine dll:
localKey = SKGL.SKM.LoadKeyInformationFromFile(keyPath, True, False)
The line is preceded by a test statement calling Newtonsoft.Json.JsonSerializer, which works fine.
When launched from Visual Studio debug, the add-in works fine.
When the WPF project is installed via MSI, the WPF application works fine.
In the install folder, the version of Newtonsoft.JSON.dll is 11.0.2.21924. This is the same for a clean install on a machine which has never had it installed before.
Our Bar.dll.config contains the xml inserted by the nuget install process to redirect existing references:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Neither Newtonsoft nor SKGLExtension are in the GAC.
All references within our code have the Require Specific Version flag set to False.
Both the solution's packages and the user's packages folder have been cleared. All builds are performed as full clean and builds.
If I try and copy the dlls over from the WPF install to the Excel install we still get the same issue.
I think it can be solved with the new Nuget package, which ensures that SKGLExtesion references the Nuget version of Newtonsoft.Json instead of a local package, which was the case earlier.
After exhausting our options, we have unfortunately had to remove the nuget reference to the SKGLExtension package. Fortunately, we were able to compile the SKGL library from source against the Newtonsoft.Json package version 11, which has resolved the issue. It would have been nice to find a better solution, though
User contributions licensed under CC BY-SA 3.0