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

B. Clay Shannon picture B. Clay Shannon · Oct 11, 2013 · Viewed 65.4k times · Source

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"

Answer

OhMyGeo picture OhMyGeo · Mar 12, 2014

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