1

I'm trying to run a c# web api project and I get the following error when I run it

Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

So I went to package manager and updated NewtonSoft.Json and that error is resolved. However then I go and run the project then I get the following error

Additional information: Could not load file or assembly 'System.Web.Http.WebHost, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

Could not load file or assembly 'System.Web.Http 4.0.0 after update from 2012 to 2013

from this link I tried

Update-Package Microsoft.AspNet.WebApi -reinstall

But now I'm getting the first error again. It's seems like I'm stuck in a circle and can't figure out how to get it to resolve. Any idea's? Seems like System.Web.Http.WebHost uses an earlier version of NewtonSoft.Json

Community
  • 1
  • 1
Derked
  • 934
  • 10
  • 17

3 Answers3

0

Try with the solution:
1. Open packages.config in your current project.
2. Delete the line: package id="Newtonsoft.Json"
3. Save.
4. Re-add Newtonsoft.Json from NuGet. Build and Run project.

0

You can try these steps:

Go to your packages folder delete the folder with Newtonsoft.Json written on it. Any project that is having reference to that will show yellow exclamation over Newtonsoft.Json in References. Remove this reference.

Check which version of NewtonSoft.Json is required from packages.json file of project and Re-add the specific version of Newtonsoft.Json from Package Manager Console.

Pushpendra
  • 1,694
  • 14
  • 27
  • When I do that, I get the second error. I think Ninject is expecting System.Web.Http.WebHost to be Version=5.0.0.0, but in my webconfig it's 5.2.3.0 – Derked Jun 07 '16 at 04:19
0

After you solve the first message, the second message is asking you to install specific version of specific packge,

you can see the version of package by clciking on nuget package manager:

enter image description here

or in Solution Explorer > References > rigt click on the reference > Properties

enter image description here


and to find the specific version of package, you can use keyword **nuget PACKAGENAME** to goolge,

.

in the case

System.Web.Http.WebHost, Version=5.0.0.0,

google "nuget System.Web.Http.WebHost" and enter the first result you'll enter

https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/

.

and scroll down you'll find many older version of the package,

enter image description here

.

open the link 5.0.0.0,

and you'll see the install command:

To install Microsoft ASP.NET Web API 2 Web Host, run the following command in the Package Manager Console

Install-Package Microsoft.AspNet.WebApi.WebHost -Version 5.0.0

enter image description here

.

I think the problem will be solved after you install the specific version of packages the message ask you to.

Community
  • 1
  • 1
yu yang Jian
  • 6,680
  • 7
  • 55
  • 80