System.Net.Http.Formatting.dll causing problems with Newtonsoft.Json
My windows service is in the same solution as the MVC project.
The MVC project uses a link to SignalR Client which requires Newtonsoft.Json v6 +
Windows service uses System.Net.Http.Formatting which requires Newtonsoft.Json version 4.5.0.0.
I assumed this would not be a problem as I could just use the binding redirection in my App.Config, however I get the error
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 = 4.5.0.0, Culture = neutral, PublicKeyToken = 30ad4fe6b2a6aeed' or one of its dependencies. the installed assembly manifest definition does not match the assembly Help. (Exception from HRESULT: 0x80131040)
my app.config has the following:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
I added that myself and it doesn't work, I also tried uninstalling and reinstalling Json.Net using nuget package manager but to no avail
source to share
Does assemblyBinding match the correct xmlns schema? Make sure the problem you are having is the same as Assembly Binding Redirection not working
source to share
We ran into the same error and tried to fix it for several days. We finally found that this is a stack overflow message Assembly reference could not be resolved - dependent assembly issue?
This made us realize that the System.Net.Http.Formatting
version is in System.Net.Http.Formatting
use and we found that our solution uses multiple versions System.Net.Http.Formatting.dll
and each of them refers to a different version. Newtonsoft.Json.dll
...
Removing links from the old version System.Net.Http.Formatting
and adding links back fixed the problem.
Hope this helps.
source to share
@ chintan123 actually pointed me in the right direction, it turned out that, despite the fact that the class library created by me was a reference both System.Net.Http.Formatting
on Newtonsoft.Json
, only the first copy to the directory bin
directory causes a project that needed it.
Adding a link to Newtonsoft.Json
the main calling project is the Newtonsoft.Json
problem.
source to share