Thursday, 6 February 2014

Updated Json.Net and now OWIN errors

I took the step on an Asp.Net MVC 5 application last night to update all of the nuget packages in the entire application to be the latest. The main reason for this was I added SignlR to the solution and it required a newer version of OWIN which is fine. With the update of all packages came the update to Json.Net to the newly released version 6 and on fire up of the application I got the following error:

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)

Using the information in the error message I added the following snippet into the runtime element in the web.config to resolve the issue:

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

I think nuget is a great concept but I still think there is a bit of an issue when it comes to multi packages which rely on a specific package which then is updated later if you update all. In the future I will be more selective on which packages to update.

2 comments:

Maxime Rouiller said...

Try upgrading with the -Safe flag. Packages won't be upgraded to major version but will upgrade to newer minor version.

Adam Storr said...

Thanks Maxime for the tip!