2

I am using Nhibernate in my MVC3 site. I have 4 tables in database and a service which is used by the site to get data from database. Now I am getting this error :

Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.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 found out that by installing the Newtonsoft.Json by NuGet instead of adding reference to its dll solves the problem, so I did that and it solved the problem. When i debug all works fine. But when I publish and upload on my staging server, it gives the error I mentioned above.

Also, please note that I have 3 methods in my service, but only one gives the error, rest all works fine. And even that one method works fine locally. Just cannot on staging.

Edit: Now i uninstall the Newtonsoft.Json by NuGet and then i added reference to Newtonsoft.Json dll kept in the Bin folder of the Project. Again its working locally but not on server.

Why so?

Please reply.

Thanks.

Deeps
  • 557
  • 9
  • 31
  • You don't happen to be using deployment service like appharbor for your staging server are you? If you do, you have to put the .dll outside the bin folder. – atbebtg Feb 25 '13 at 16:25

1 Answers1

0

If it works on your system locally, but does not work on the server. I would assume you have some library installed on your PC that is not available on your server.

What library could be missing is hard to say, try looking at the references in your project and see if you are referencing libraries that might be using libraries that you have installed locally.

Deruijter
  • 2,077
  • 16
  • 27
  • But it gives error for Newtonsoft.Json. And its dll is present in Bin folder. And Packages.config file created by NuGet also contains information about the dll. – Deeps Feb 25 '13 at 13:23
  • Can you check if the versions of the DLLs are the same? Also, if you are using Newtonsoft.Json in multiple projects (or third party libraries), check if they all require the same version of the DLL. Maybe this answer can help as well: http://stackoverflow.com/questions/9426723/could-not-load-file-or-assembly-newtonsoft-json-dll – Deruijter Feb 25 '13 at 13:49
  • Yes I have checked the DLLs. They are of same version. I have used Newtonsoft.Json in two projects and they both are of same version. – Deeps Feb 26 '13 at 07:07
  • 1
    Thanks Deruijter, its working now. I don't know but previously i have deleted and added reference and cleaned and built the solution. I did the same again. And now its working. May be last time i wasn't so careful. Thanks. – Deeps Feb 27 '13 at 10:13