软件包Microsoft.AspNet.WebApi.Client 5.2.3中的System.Net.Http.Formatting.dll。似乎不起作用 [英] System.Net.Http.Formatting.dll in package Microsoft.AspNet.WebApi.Client 5.2.3. doesn't seem to work
问题描述
我有一个针对.net 4.5.1框架的vb.net类库项目。我在Windows 7主页上使用Visual Studio 2013社区版。
I have a vb.net class library project targeting .net 4.5.1 framework. I am using Visual Studio 2013 community edition on Windows 7 home.
该项目是一个使用webapi 2 REST API的库。
The project is a library consuming a webapi 2 REST API.
作为指南我使用的是这个例子
As a guide I am using this example
http://www.asp.net/web-api/overview/advanced/ call-a-web-api-from-a-net-client
http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client
项目的packages.config如下:
Project's packages.config is the following:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net451" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net451" />
</packages>
项目的程序集引用是:
Project's assemblies references are:
Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL
System
System.Data
System.Net.Http
System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
<HintPath>..\..\..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
System.Xml
System.Core
System.Xml.Linq
System.Data.DataSetExtensions
app.config文件是:
app.config file is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
问题是Microsoft中定义的System.Net.Http.HttpClient扩展。未加载AspNet.WebApi.Client.5.2.3\lib\\\
et45\System.Net.Http.Formatting.dll,因此函数如$
The problem is that System.Net.Http.HttpClient extensions defined in Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll aren't loaded so functions like
&NBSP;&NBSP;&NBSP; System.Net.Http.HttpClientExtensions.PostAsJsonAsync(Of T)
和
&NBSP; System.Net.Http.HttpClientExtensions.PostAsXmlAsync(Of T)
不可用。
我发现有几个相关问题就像这样一个
System.Net.Http.HttpClientExtensions.PostAsJsonAsync(Of T)
and
System.Net.Http.HttpClientExtensions.PostAsXmlAsync(Of T)
aren't available.
I found several related questions is SO like this one
http://stackoverflow.com/questions/19158378/httpclient-not-supporting-postasjsonasync-method-c-sharp
http://stackoverflow.com/questions/19158378/httpclient-not-supporting-postasjsonasync-method-c-sharp
但是评论中提供的答案和建议对我不起作用。
我尝试了各种互联网资源的其他建议,例如:示例替换在Microsoft.AspNet.WebApi.Client包中找到的System.Net.Http.Formatting.dll的引用与扩展程序集区域中找到的引用但是也没有工作
。
现在我被卡住了,我不知道如何解决这个问题。任何帮助都将受到高度赞赏。
but the provided answers and suggestions in comments didn't work for me.
I tried several other recommendations from various internet sources, like for example replacing the reference of System.Net.Http.Formatting.dll found in Microsoft.AspNet.WebApi.Client package with the one found in the extensions assemblies area but didn't work
either.
Now I am stuck and I don't know how to solve this. Any help will be highly appreciated.
推荐答案
嗨Anna,
此论坛讨论并提出有关.NET Framework基类(BCL)的问题,例如集合,I / O,Regigistry,Globalization,Reflection。根据您的描述,您的案例与Asp.Net Web API更相关, 对于Web API问题,您应该在相关论坛中发布
。 请在以下链接中发布此问题。
This forum is discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Based on your description, your case more related to Asp.Net Web API, for web API issues, you should post in the related forum. Please post this issue in the following links.
http://forums.asp.net/1246.aspx/1?Web+API
祝你好运,
Kristin
这篇关于软件包Microsoft.AspNet.WebApi.Client 5.2.3中的System.Net.Http.Formatting.dll。似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!