簡體   English   中英

在VS 2012項目中啟用System.Net.Http

[英]Enabling System.Net.Http within VS 2012 Project

我對JSON開發還很陌生,剛剛入門是一項重要任務,只有很少的解決方案來自谷歌。

如果不在我的項目中添加system.net.http,我無法到達任何地方

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Net.Http;

var,HttpWebClient,KeyValuePair等對象在編譯期間拋出錯誤。 這是我試過的:

  • 重新安裝.NET 4.0
  • 重新安裝.NET 4.5
  • 重新包裝的庫通過。 的NuGet
  • 引用的system.net

沒運氣。 我甚至嘗試在web.config中引用該類

<compilation targetFramework="4.5">
  <assemblies>
    <add assembly="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </assemblies>
</compilation>

再次在..

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
      <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

“程序集”上引發錯誤

我的智慧結束了。 在無法使用System.Net.Http的情況下,我沒有引用或做錯。

在.NET 4.5中,System.Net.Http在它自己的程序集中,你必須轉到“添加引用”(右鍵單擊項目)並選擇它。

請參閱HttpClient的MSDN頁面: http//msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx

程序集:System.Net.Http(在System.Net.Http.dll中)

幫助系統顯示System.Net.Http命名空間在System.Net.Http.dll中定義,如您所說,未列出。 快速搜索我自己的文件系統會顯示副本

  • 在GAC中
  • 在32和64位的框架文件夾中

在我的系統上,這些路徑是

 C:\Windows\Microsoft.NET\Framework\v4.0.30319
 C:\Windows\Microsoft.NET\Framework64\v4.0.30319

System.Net.Http.WebRequest.dll位於相同的路徑上。

你試過了嗎

using System.Net.Http;

C#是一種區分大小寫的語言。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM