I have the following code to create an HttpWebRequest in my WP7 application. I’m trying to call this code from a Unit Test application which is of type “Silverlight Unit Test Application” with the target framework set to Silverlight 5. I grabbed the WP7.5 Mango Beta test assemblies from Jeff Wilcox’s blog:
public void SomeFunction()
{
Uri uri = new Uri("http://www.google.com");
HttpWebRequest request = HttpWebRequest.CreateHttp(uri);
request.Method = "POST";
...
}
In the code above, the line that creates the request throws a NullReferenceException. The stack trace doesn’t provide anything of value.
Is this happening because I’m using an SL Test Application?
Windows Phone 7.5 uses Silveright 4, not 5, but it’s not compatible with the desktop versions of either (unit tests must be run from the WP emulator).
To create a WP test project:
Loadedevent handler:_
On topic, you might be able to resolve the issue by re-registering the correct handlers:
However, I’d recommend you just start again.