Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference System.Net.Http in WP8?

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();
                });
like image 201
anthonyhumphreys Avatar asked Jun 30 '13 19:06

anthonyhumphreys


People also ask

What is System Net HTTP?

Provides a programming interface for modern HTTP applications, including HTTP client components that allow applications to consume web services over HTTP and HTTP components that can be used by both clients and servers for parsing HTTP headers. Commonly Used Types: System. Net.


1 Answers

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

like image 198
keyboardP Avatar answered Oct 06 '22 00:10

keyboardP