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

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.

This question is related to c# asp.net .net asp.net-mvc-4

The answer is


I was facing the same problem because

System.Net.Http.Formatting

version written inside webconfig was 5.0.3 but inside the bin folder the library System.Net.Http.Formatting dll version was 4.0.2

so I just replaced with the same given inside bin

enter image description here

enter image description here

just do this clean project and build


  1. Remove all code references to System.Net.*
  2. Uninstall: Package Microsoft.AspNet.WebApi and its dependencies.
  3. Reinstall all: Package Microsoft.AspNet.WebApi and its dependencies.
  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

VS2019: Tools -> Nuget Package Manager -> Package Manager Setting -> in Package Restore section, check 2 options. After that, go to project packages folder and delete all child folders inside (for no longer any error) Then Rebuild solution, Nuget will redownload all packages and project should run without any reference.


As originally suggested in a comment by GeoMac and documented on NuGet's docs the following worked for me when none of the other answers worked:

Tools / NuGet Package Manager / Package Manager Console

Update-Package -ProjectName MyProjectName -reinstall

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;

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.


For those that use .NET Standard project in combination with .NET Framework projects:

In the .NET Standard way, packages that are included in a .NET Standard project will correctly be used across other .NET Core and .NET Standard projects.

Im the .NET Framework way, if you are referring to a .NET Standard project from an .NET Framework (MVC) project, you need to manually download and install the same nuget packages.

So the answer to my question was that I had to download and install Microsoft.AspNet.WebApi.Client in the web project (.NET Framework) that is using a .NET Standard project where Microsoft.AspNet.WebApi.Client is needed. In fact, I already had this installed but there was a version difference.

I just add this answer for others to see, it might not directly answer OP's question but it did save me time by first checking this instead of doing the top-voted answers.


What I did to solve this problem is

  1. Go to NuGet package manager.

  2. Select Updates (from the left panel)

  3. Update WebApi components

  4. After that, the project ran without errors.


What solved this annoying error for me was just to close Visual Studio and open it again. Then rebuild the solution, and it all worked again. Sorry for the crap answer, but I think it's worth an answer because it solved it for me.


In my case, none of the above worked, however, replacing 5.2.3.0 with 4.0.0.0 did solve the problem.


Removing the following lines from web.config solved my problem. Note that in this project I didn't use WebApi components. So for others this solution may not work as expected.

  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
  </dependentAssembly>

I found an extra

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

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


I had the problem with a ASP.NET project in VS 2019.

Another symptom was, that some references (System.Web.Http) were marked as faulty in the project references list (Solution Explorer)

My solution:

  1. Delete the faulty references in Project -> References (right click, ...)
  2. Build
  3. Navigate to the build errors "The type or namespace name [...] could not be found" or similar
  4. Use the "Show potential fixes" -> Install package

The cause:

Looking at the difference in the csproj file I could see the reason for the trouble. Someone managed to reference a DLL in the Windows Program file folder!

<Reference Include="System.Web.Http">
  <HintPath>..\..\..\..\..\..\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\..\..\..\..\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll</HintPath>
</Reference>

  • Remove all code references to System.Net.*

  • in the package window,

    Install-Package Microsoft.AspNet.WebApi.Client

  • Clean and rebuild your project


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.


In my case none of the above solutions worked. I solved by right clicking on the reference

System.Net.Http.Formatting

from Visual studio and setting the property Copy Local to true.

I hope this is useful somehow.


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to asp.net

RegisterStartupScript from code behind not working when Update Panel is used You must add a reference to assembly 'netstandard, Version=2.0.0.0 No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization How to use log4net in Asp.net core 2.0 Visual Studio 2017 error: Unable to start program, An operation is not legal in the current state How to create roles in ASP.NET Core and assign them to users? How to handle Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause() ASP.NET Core Web API Authentication Could not load file or assembly 'CrystalDecisions.ReportAppServer.CommLayer, Version=13.0.2000.0 WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jquery

Examples related to .net

You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to use Bootstrap 4 in ASP.NET Core No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Update .NET web service to use TLS 1.2 EF Core add-migration Build Failed What is the difference between .NET Core and .NET Standard Class Library project types? Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies Nuget connection attempt failed "Unable to load the service index for source" Token based authentication in Web API without any user interface

Examples related to asp.net-mvc-4

Better solution without exluding fields from Binding How to remove error about glyphicons-halflings-regular.woff2 not found When should I use Async Controllers in ASP.NET MVC? How to call controller from the button click in asp.net MVC 4 How to get DropDownList SelectedValue in Controller in MVC Return HTML from ASP.NET Web API There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key country Return JsonResult from web api without its properties how to set radio button checked in edit mode in MVC razor view How to call MVC Action using Jquery AJAX and then submit form in MVC?