I found that my console app (.NET Core 2.2) was blowing up because there seemed to be some kind of conflict between dependencies for JSON.NET (Newtonsoft).
This was the exception:
System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=18.104.22.168, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Upon further investigation, I discovered the cause of the exception, which I will lay out below.
I have a reference to a local Project which depends on JSON.NET. Let's call it
SomeDomain. That relies on v12.0.2 of JSON.NET.
I also have installed (by way of Nuget), the package
Microsoft.Extensions.Configuration.Json (v2.2.0) which also relies on JSON.NET. If you go to the Nuget.org page for that version of that package, you'll see the version dependancy is >= 11.0.2
I'm thinking "sweet".
When I publish, it is resolving v11.0.2 of JSON.NET. And this leads to an exception, because
SomeDomain depends on v12.0.2 .
In an attempt to resolve this, I added v12.0.2 of JSON.NET directly to the app. I figured this would force it to use that version. Not so. It still resolves v11.0.2 of JSON.NET upon Publish.
Does anyone know how I can force it to resolve v12.0.2 of JSON.NET when I publish my app?
User contributions licensed under CC BY-SA 3.0