¿Desde dónde hago referencia a un ensamblado que falta (System.Net.Http. Formatting)?


En mi proyecto de Visual Studio 2013 RC, estoy recibiendo este mensaje err:

"Se define el tipo 'System.Net.Http.Formatting. MediaTypeFormatter' en un ensamblado al que no se hace referencia. Debe agregar una referencia a assembly ' System. Net. Http. Formatting, Version=4.0.0.0, Cultura = neutral, PublicKeyToken=31bf3856ad364e35'"

...en la línea de código "var response = " en un Controlador:

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;
}

Buscando en mi disco duro el ensamblaje requerido ("System.Net.Http.Formatting"), me muestra varias ubicaciones donde existe, pero todas están dentro de proyectos existentes, como se ve aquí:

introduzca la descripción de la imagen aquí

Seguramente hay otro lugar desde el cual System.Net.Http.Formatting.dll puede ser referenciado! ¿Pero dónde?

ACTUALIZACIÓN

Tratando de seguir la pista aquí: http://www.nuget.org/packages/System.Net.Http.Formatting

IOW, seleccionando Herramientas > Gestor de paquetes de biblioteca > Consola de Gestor de paquetes , y entrada:

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

...Veo los toros rojos de Pamplona (no la bebida) descendiendo con los ojos salvajes sobre mí:

introduzca la descripción de la imagen aquí

ACTUALIZACIÓN 2

He añadido la System.Net.Http.Formatting.dll desde aquí:

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

...y ahora compila y se ejecuta y funciona como se esperaba, pero eso obviamente "no es el método preferido"

Author: Leandro Tupone, 2013-10-11

4 answers

Yo tenía el mismo problema. Usé Microsoft Asp Net WebAPI Client 4.0.20710 y funcionó para mí.

Escriba el siguiente comando en Herramientas > Gestor de paquetes de biblioteca > Consola del Gestor de paquetes:

Install-Package Microsoft.AspNet.WebApi.Client -Version 4.0.20710
 71
Author: OhMyGeo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-10-28 11:27:27

Añadiendo a lo que Luiz respondió arriba.

System.Net.Http.Formatting es una biblioteca y se utiliza para el formato de tipo de medio. Por ejemplo: http://msdn.microsoft.com/en-us/library/system.net.http.formatting.jsonmediatypeformatter(v=vs. 118).aspx

Al referenciarlo, cuando lo intenté, estaba buscando agregar una referencia en mi proyecto y estaba buscando en la carpeta Assemblies/Framework en Reference Manager.

En realidad se encuentra en la carpeta Assemblies/Extensions en Gestor de referencias

 41
Author: Cameron,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-16 13:35:58

Si tiene un error al intentar instalar System. Net. Http. Formatting-Version 4.0.20710 , pruebe esto:

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

Acabo de encontrar en NuGet: https://www.nuget.org/packages/WebApiDoodle.Net.Http.Formatting/3.0.0-pre01

 7
Author: Luiz Felippe Gonçalves,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-06-19 23:46:06

Haga clic derecho en el proyecto y haga clic en Agregar una opción de referencia, luego vaya a Extensiones desde Ensamblajes pestaña y elija System.Net.Http. Formatting. Si no está aquí, debe agregar manualmente archivos prgramme - > Microsoft ASP.NET

 4
Author: Ganganath Rathnasekara,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-14 07:43:56