如何在WP8中引用System.Net.Http?

我对WP8开发相对较新,并且遇到了一个我无法弄清楚的问题,即使经过数小时的谷歌搜索。

我正在使用visual studio 2012并使用NuGet实现了System.Net.Http,检查了引用,copy local设置为true,但它不会构建。

这是一个问候我的错误消息:

CA0001 Error Running Code Analysis CA0001 : The following error was encountered while reading module '3D Protect Premium': Could not resolve member reference: [System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]System.Net.Http.HttpClient::PostAsync. [Errors and Warnings] (Global) 

我如何解决这个问题,所以引用的版本是正确的?

编辑

代码在下面添加。 这似乎不成问题,它只是引用 – 我认为我的误解是诚实的,我只是不知道什么是System.Net.Http汇编!

 //Creates a new HttpClient Instance var client = new HttpClient(); // This is the postdata // Data forms an array and is used to populate the remote MySQL DB var postData = new List<KeyValuePair>(); postData.Add(new KeyValuePair("name", "windowsphonetest")); postData.Add(new KeyValuePair("latitude", LatitudeString)); postData.Add(new KeyValuePair("longitude ", LongitudeString)); postData.Add(new KeyValuePair("devID", "test")); HttpContent content = new FormUrlEncodedContent(postData); //The actual HTTP Transaction client.PostAsync("http://blah.com", content).ContinueWith( (postTask) => { postTask.Result.EnsureSuccessStatusCode(); }); 

您尝试使用的System.Net.Http包已被弃用,但您可以使用Microsoft.Net.Http 。

解决方案:删除所有相关的NuGet包,清理解决方案,删除对System.Net。*程序集的引用。

按照NuGet的建议安装Microsoft.Net.Http及其依赖项。 然后安装Microsoft.Bcl.Async – 这是一个不被NuGet标记的依赖项(感谢keyboardP)

现在进入项目属性并禁用“构建时的代码分析” – 由于某种原因,此工具会因版本号而跳闸。 现在代码构建和部署很好。