From where do I reference a missing assembly (System.Net.Http.Formatting)?

.Net AssemblyVisual Studio-DebuggingVisual Studio-2013system.netMediatypeformatter

.Net Assembly Problem Overview


In my Visual Studio 2013 RC project, I'm getting this err msg:

> "The type 'System.Net.Http.Formatting.MediaTypeFormatter' is defined > in an assembly that is not referenced. You must add a reference to > assembly 'System.Net.Http.Formatting, Version=4.0.0.0, > Culture=neutral, PublicKeyToken=31bf3856ad364e35'"

...on the "var response = " line of code in a Controller:

public HttpResponseMessage PostDelivery(Delivery delivery)
{
    delivery = repository.Add(delivery);
    var response = Request.CreateResponse<Delivery>(HttpStatusCode.Created, delivery);

    string uri = Url.Link("DefaultApi", new { id = delivery.Id });
    response.Headers.Location = new Uri(uri);
    return response;
}

Searching my hard drive for the required assembly ("System.Net.Http.Formatting"), it shows me several locations where it exists, but they are all within existing projects, as is seen here:

enter image description here

Surely there is another location from which System.Net.Http.Formatting.dll can be referenced! But where?

UPDATE

Trying to follow the clue here: http://www.nuget.org/packages/System.Net.Http.Formatting

IOW, by selecting Tools > Library Package Manager > Package Manager Console, and entering:

Install-Package System.Net.Http.Formatting -Version 4.0.20710

...I see the red bulls of Pamplona (not the beverage) descending wild-eyed upon me:

enter image description here

UPDATE 2

I added the System.Net.Http.Formatting.dll from here:

C:\Users\clay\My Documents\Visual Studio 2013\Projects\MvcApplication1\MvcApplication1\bin

...and it now compiles and runs and works as expected, but that is obviously "not the preferred method"

.Net Assembly Solutions


Solution 1 - .Net Assembly

I had the same problem. I used Microsoft Asp Net WebApi Client 4.0.20710 and it worked for me.

Type the following command into Tools > Library Package Manager > Package Manager Console:

Install-Package Microsoft.AspNet.WebApi.Client -Version 4.0.20710

Solution 2 - .Net Assembly

Adding to what Luiz answered above.

System.Net.Http.Formatting is a library and is used for media type formatting. For example: http://msdn.microsoft.com/en-us/library/system.net.http.formatting.jsonmediatypeformatter(v=vs.118).aspx

When referencing it, when I tried, I was looking to add a reference in my project and was looking in the Assemblies/Framework folder in Reference Manager.

It is actually in the Assemblies/Extensions folder in Reference Manager

Solution 3 - .Net Assembly

If you got an error trying to install System.Net.Http.Formatting -Version 4.0.20710, try this one:

Install-Package WebApiDoodle.Net.Http.Formatting -Pre

I just found on NuGet: https://www.nuget.org/packages/WebApiDoodle.Net.Http.Formatting/3.0.0-pre01

Solution 4 - .Net Assembly

Right click on project and click Add a reference option, then go to Extensions from Assemblies tab and choose System.Net.Http.Formatting. If it is no in here you have to manually add in prgramme files-> Microsoft ASP.NET

Solution 5 - .Net Assembly

One other simple option for resolving this is to right click on references, click 'Manage NuGet References', Browse for 'Microsoft.AspNet.WebApi.Client' and install it or perhaps reinstall it. Review the package information to learn more.

Solution 6 - .Net Assembly

I ran into the same problem on vs2022 v16.11.5.
I was fortunate enough to have the project working on one machine but not another. On the suspect machine, under project References, System.Net.Http.Formatting could not be found. Running the visual studio installer app and modifying the vs2022 install to include the ASP.NET and web development package fixed me up.

ASP.NET and Web development Install image

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionB. Clay Shannon-B. Crow RavenView Question on Stackoverflow
Solution 1 - .Net AssemblyOhMyGeoView Answer on Stackoverflow
Solution 2 - .Net AssemblyCameronView Answer on Stackoverflow
Solution 3 - .Net AssemblyfelippeDevView Answer on Stackoverflow
Solution 4 - .Net AssemblyGanganath RathnasekaraView Answer on Stackoverflow
Solution 5 - .Net AssemblyGrayDwarfView Answer on Stackoverflow
Solution 6 - .Net AssemblyJT-SeniorTestEngineerView Answer on Stackoverflow