c# version= - Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The system cannot find the path specified

7 Answers

Whenever I have a NuGet error such as these I usually take these steps:

  1. Go to the packages folder in the Windows Explorer and delete it.
  2. Open Visual Studio and Go to Tools > Library Package Manager > Package Manager Settings and under the Package Manager item on the left hand side there is a "Clear Package Cache" button. Click this button and make sure that the check box for "Allow NuGet to download missing packages during build" is checked.
  3. Clean the solution
  4. Then right click the solution in the Solution Explorer and enable NuGet Package Restore
  5. Build the solution

Taking all of these steps almost always restores all the packages and dll's I need for my MVC program.

EDIT >>>

For Visual Studio 2013 and above, step 2) should read:

  1. Open Visual Studio and go to Tools > Options > NuGet Package Manager and on the right hand side there is a "Clear Package Cache button". Click this button and make sure that the check boxes for "Allow NuGet to download missing packages" and "Automatically check for missing packages during build in Visual Studio" are checked.
5.2.6 core

I have a small MVC app that I use for practice reasons, but now I am encountering an error every time I try to debug:

Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. 
The system cannot find the path specified.

I've googled but cannot find a solution. I'm using .NET 4.5.

It can't be the DLL file because I'm using .Net 4.5.

I found an extra

    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="" newVersion="" />

in my web.config. removed that to get it to work. some other package I installed, and then removed caused the issue.

user3919888 pointed me in the right direction, but I needed to run Update-Package -reinstall Microsoft.AspNet.WebApi.Client in the Package-Manager console. Basic install by itself does not recognize the problem but does recognize that the package is already installed and does not overwrite it.

I'm posting this answer because this happens so infrequently that I end up googling and reaching this page before I remember what I did last time.

  1. Remove all code references to System.Net.*
  2. Uninstall:Package Microsoft.AspNet.WebApi and its dependent.
  3. Reinstall all : Package Microsoft.AspNet.WebApi and its dependent.
  4. Clean and rebuild your project

For me it was as simple as

  1. Delete Microsoft.AspNet.WebApi.Client from the packages folder in Windows Explorer
  2. Open Tools > NuGet Package Manager > Package Manager Console
  3. Click the "Restore" button

Probably you need to set library reference as "Copy Local = True" on properties dialog. On visual studio click on "references" then right-click on the missing reference, from the context menu click properties, you should see copy local setting.

For Me adding few below line in WebApi.config works as after updating the new nuget package did not works out

var setting = config.Formatters.JsonFormatter.SerializerSettings;
setting.ContractResolver = new CamelCasePropertyNamesContractResolver();
setting.Formatting = Formatting.Indented;

Don't forget to add namespace:

using Newtonsoft.Json.Serialization; 
using Newtonsoft.Json;


c# asp.net .net asp.net-mvc-4