2

I get the following error every day:

Exception information: 
Exception type: FileLoadException 
Exception message: Could not load file or assembly 'Newtonsoft.Json, Version=4.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 can temporarily fix it by renaming the dll and then reverting the rename. I've check the web config for the proper assembly redirect:

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

I have also checked the file assembly version number and that is 4.5.0.0 It's version 5.0.8 of the Newtonsoft.Json package.

enter image description here

How is it possible that this error keeps occurring everyday? What are the possible causes?

This problem seems to be fixed now. I manually cleaned the entire solution locally and also on the webserver. And did a clean deployment.

PeterB
  • 43
  • 6
  • Maybe you have a backup system that is locking the file at the same time you're program is trying to load it? – Ron Beyer Jun 15 '15 at 14:24
  • It's always the same dll of the same website. If this was the case i'd expect other dll's or other projects to show similair errors. – PeterB Jun 15 '15 at 14:30
  • "4.5.0.0 It's version 5.0.8 of the Newtonsoft.Json package" - this statement feels wrong. Usually version of Newtonsoft.Json matches version of NuGet... Usually the wrong version is brought in by System.Web.Http assembly - check out if you use it. – Alexei Levenkov Jun 15 '15 at 14:41
  • I've added a picture of the version information. Newtonsoft.Json used the targeted .net version of it's dll as the assembly version I believe. I do use System.Web.Http. But a request to the wrong version should be redirected by the bindingRedirect in the web.config. Also I expect that the website would never work if this was the problem. – PeterB Jun 15 '15 at 14:49
  • Is another component using a newer version of Newtonsoft.Json? Is any Newtonsoft.Json in the GAC (probably not what you want)? Renaming a .dll will force an application pool recycle, might be a clue as well. – Caramiriel Jun 15 '15 at 15:09
  • I've checked the GAC using gacutil. It finds no assemblies. If a recycle of this website 'fixes' it, could a recycle of another website that uses a different version break it? – PeterB Jun 15 '15 at 15:24
  • No, that shouldn't fix it (the app recycle on a different website) as they are seperate, and no NewtonSoft library is found in the GAC. Maybe somewhere in the code you're loading a previous version? Also: could you perhaps post all your assembly redirects? – Steven Lemmens Jun 29 '15 at 12:04
  • I suspect I didn't deploy the website correctly leaving some old dll's in place that caused a conflict. I did a major update of the website and then rolled it back because of an error. I think something was left behind that should have been deleted. – PeterB Jun 29 '15 at 12:50

0 Answers0