如何引用System.Net.Http在WP8? [英] How to reference System.Net.Http in WP8?

查看:228
本文介绍了如何引用System.Net.Http在WP8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是比较新的WP8发展和所遇到的,我只是想不通,甚至谷歌搜索小时后的问题。



我使用的可视化Studio 2012中并使用的NuGet,已签引用实施System.Net.Http,复制本地设置为true,但不会建立。



这是映入眼帘的是错误信息我:

  CA0001错误运行代码分析CA0001:读取模块3D保护溢价时遇到以下错误:无法解析成员引用:[System.Net.Http,版本= 1.5.0.0,文化=中性公钥= b03f5f7f11d50a3a] System.Net.Http.HttpClient :: PostAsync。 [错误和警告](全球)



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



修改



下面的代码添加。这似乎没有什么问题,但是它只是引用 - 我认为它我的误解,说实话,我只是没有一个线索什么的System.Net.Http装配回事!



  //创建一个新的HttpClient的实例
VAR的客户=新的HttpClient();

//这是POSTDATA
//数据构成的阵列和用于填充远程MySQL数据库
变种POSTDATA =新列表与所述; KeyValuePair&下;串,串GT;> ;();
postData.Add(新KeyValuePair<字符串,字符串>(名,windowsphonetest));
postData.Add(新KeyValuePair<字符串,字符串>(纬度,LatitudeString));
postData.Add(新KeyValuePair<字符串,字符串>(经度,LongitudeString));
postData.Add(新KeyValuePair<字符串,字符串>(DEVID,测试));


HttpContent内容=新FormUrlEncodedContent(POSTDATA);

//实际的HTTP交易
client.PostAsync(http://blah.com,内容).ContinueWith(
(postTask)=>
{
postTask.Result.EnsureSuccessStatusCode();
});


解决方案

System.Net。 HTTP 你想使用已过时,但你可以使用微软包.Net.Http 代替。


I am relatively new to WP8 development and have come across a problem that i just cannot figure out, even after hours of googling.

I am using visual studio 2012 and have implemented System.Net.Http using NuGet, have checked references, copy local is set to true, but it will not build.

This is the error message which greets me:

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)

How do i fix this so the referenced version is correct??

Edit

Code added below. This doesnt seem to be problematic, its just the referencing - i think its me misunderstanding to be honest, i Just dont have a clue whats going on with the System.Net.Http assembly!!

//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();
                });

解决方案

The System.Net.Http package you're trying to use has been deprecated but you can use Microsoft.Net.Http instead.

这篇关于如何引用System.Net.Http在WP8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆