I am trying to use SocketIO4Net to create socket.io client in .net. Itseems SocketIO4Net has a dependency of Newtonsoft.Json >= 4.0.8. I also am using PushSharp library which has a Newtonsoft.Json dependency of >= 4.5.10. I got NewtonSoft.Json 4.5.11 when i first installed PushSharp and I thought this version should support SocketIO4Net as well since its a higher version but i get this error whenever am trying to connect to socket.io server.
Could not load file or assembly 'Newtonsoft.Json, Version=4.0.8.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)
I have been banging my head all day with these dependency issues, I would be very grateful if someone can point me in the right direction.
Got the above Error: in Visual Studio 2013 To Fix: In package mamnager Execute: Install-package newtonsoft.json This will add a new line in packages.config
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" />
Remove the previous line which might point to previous version on packages.config. Delete the old version's directory on the packagers directory. Remove the reference of NewtonSoft.Json and readd it pointing to the latest version. Root webconfig will have the following<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
once everything is done. Close and reopen visual studio. This should fix it. I had the same error when installing PM> install-package durandal.starterkit I used the above method to fix.You can modify assembly-binding configuration and add a redirect. See Redirecting Assembly Versions on MSDN.
Basically you want to add following snippet to your
app.config
orweb.config
file:EDIT
Why do you need to redirect assembly versions? Even though SocketIO4Net supports newer versions of Newtonsoft.Json, it was compiled against a single version (4.0.8 in your case). This version is stored in the DLL and it is used to load DLLs SocketIO4Net depends on.
Note that NuGet dependencies are not the same as DLL/runtime dependencies - NuGet dependency on Newtonsoft.Json >= 4.0.8 only means that you will be allowed to install SocektIO4Net into a project that has a newer version of Newtonsoft.Json, it has nothing to do with runtime settings.
That being said, recent NuGet versions should add assembly-binding-redirects automatically for you if your project has app.config or web.config file.
Had this same issue.
Just resolved it.
It happened after NuGet was used to install Ext.NET which has a dependency for Newtonsoft.JSON.
There was already a Newtonsoft.JSON.dll file in /bin (and obviously a reference to it in the web.config file) folder without checking I started the NuGet Package-Install procedure while debugging(so the file probably had a lock).
On the runtime error window it will tell you on the stack trace what part of the manifest it has a problem with, mine was major version so I checked the install package version. and it was 1 major version out. Found the original NuGet file under: "[physical path]/../packages/Newtonsoft.Json.[version]/lib/[.net version]/"
Both Manifest and Library was there so copied it into /bin folder, updated the root web.config assembly information and it worked.
Code samples: Before
After
Hope this helps
The above solutions are correct but there is one more point that should not be forgotten: the app.config content was the same as the above solutions.
But it's a good idea to check if it's up to date. In my case, Newtonsoft.JSON (v.6.0.4) has come to depend on another package.
There are two option;