LiamHT LiamHT -4 years ago 246
ASP.NET (C#) Question causing issues with Newtonsoft.json

My Windows service is in the same solution as a MVC project.

The MVC project uses a reference to SignalR Client which requires Newtonsoft.Json v6 +

the Windows service uses System.Net.Http.Formatting, which requires Newtonsoft.Json version

I assumed this would not be a problem, as I could just use a binding redirect in my App.Config, however I get an error of

An unhandled exception of type 'System.IO.FileLoadException' occurred
in System.Net.Http.Formatting.dll

Additional information: Could not load file or assembly
'Newtonsoft.Json, Version=, 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)

my app.config has the following:

<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="" newVersion=""/>

I added that myself, and it does not work, I have also tried uninstalling and re-installing Json.Net with the nuget package manager, to no avail

Answer Source

Does the assemblyBinding tag have proper xmlns schema? Check if the issue you are encountering is same as Assembly binding redirect does not work

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download