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.Solution: Delete all dependent NuGet packages, cleaning solution, deleting references to System.Net.* assemblies.
Install Microsoft.Net.Http and its dependencies as suggested by NuGet. Then install Microsoft.Bcl.Async - this is a dependency which is not flagged by NuGet (thanks keyboardP)
Now go into project properties and disable 'Code analysis on build' - this tool is tripping up over the version number for some reason. Now the code builds and deploys fine.