开发者

Random System.NotSupportedException on WP7

开发者 https://www.devze.com 2023-03-06 13:28 出处:网络
Sporadically, I receive an error in my WP7 Silverlight application. The error is a random \"System.NotSupportedException\". This error is thrown occassionally when the following code is executed:

Sporadically, I receive an error in my WP7 Silverlight application. The error is a random "System.NotSupportedException". This error is thrown occassionally when the following code is executed:

// 1. Build the url
string serviceURL = "http://www.mydomain.com/service.svc/param1/param2";

// 2. Asynchronously execute the query using HttpWebRequest instead of WebClient. There is a UI performance issue with the WebClient currently
WebRequest request = HttpWebRequest.Create(serviceUrl);
request.BeginGetResponse(new AsyncCallback(MyService_Completed), request);

...

private void MyService_Completed(IAsyncResult result)
{
  // Do stuff
}

I have verified that the URL I am sending is correct. Please note, that this request is part of my view model, which may have other network requests fired off at the same time. I have no idea why this happens ocassionally. Can anybody point out any potential reasons?

开发者_开发百科Thank you!


When this happens, make sure you look at the View Detail part of the exception report. It might be that your service is refusing connection or the data passed is invalid. NotSupported is a very general exception that covers many possible situations.


A similar question has been asked previously. If you look at the comments the original poster added to the answer, he claims to have solved the problem by replacing

request.BeginGetResponse(new AsyncCallback(MyService_Completed), request);

with

request.BeginGetResponse( MyService_Completed, request);
0

精彩评论

暂无评论...
验证码 换一张
取 消