我对 WP8 开发相对较新,并且遇到了一个我无法弄清楚的问题,即使经过数小时的谷歌搜索。
我正在使用 Visual Studio 2012 并使用 NuGet 实现了 System.Net.Http,检查了引用,将本地复制设置为 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<string, string>>();
postData.Add(new KeyValuePair<string, string>("name", "windowsphonetest"));
postData.Add(new KeyValuePair<string, string>("latitude", LatitudeString));
postData.Add(new KeyValuePair<string, string>("longitude ", LongitudeString));
postData.Add(new KeyValuePair<string, string>("devID", "test"));
HttpContent content = new FormUrlEncodedContent(postData);
//The actual HTTP Transaction
client.PostAsync("http://blah.com", content).ContinueWith(
(postTask) =>
{
postTask.Result.EnsureSuccessStatusCode();
});