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.
Found solution, try with:
Just had this happen with TeamCity and I imagine others will soon experience this. This probably applies to most build servers that pull NuGet packages.
All the answers that say to do redirects are correct. However, you need to still define the correct version number. My project was using
Newtonsoft.Json 7.0
, however, they had just released8.0
and TeamCity was pulling down8.0
which was causing issues only on the server and not locally. All my redirects were set to7.0
.Make sure that the deployed application is actually getting the correct version from NuGet and not just the latest and greatest. Or update your config to point to the newest version.
In my case, I removed the package with NuGet and installed a fresh one. Then, remove the reference from References and add again manually. Works like charm. Hope resolve for you.
I was working on an old project recently. I needed to update our Newtonsoft.Json.dll, since I had to utilize a "new" API which required a newer version, but I still had other DLLs that required the old version.
bindingRedirect you say? Nope. It kept complaining about the manifest mismatch.
Separate codeBase tags? Nope. It kept complaining about the manifest mismatch.
The problem was, apparently, that the old version of Newtonsoft.Json.dll (3.0.0.0) does NOT have a PublicKeyToken, but the "new" version (4.5.7.1) DOES have a PublicKeyToken. Therefore they couldn't share the same dependentAssembly-tag.
This is what I ended up with:
Put in an assembly redirect in your app/web.config;
Please note the versions numbers need to match the version you have installed.
I have fixed this issue easily: I had not copied the xml configuration file from the compilation folder.
I just made sure that the xml configuration file was also included along with my program and everything worked fine!