2011-05-16 57 views
0

偶爾,我在WP7 Silverlight應用程序中收到錯誤。該錯誤是隨機的「System.NotSupportedException」。執行以下代碼時偶爾會引發此錯誤:WP7上的隨機System.NotSupportedException

// 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 
} 

我已驗證我發送的網址是否正確。請注意,這個請求是我的視圖模型的一部分,它可能會同時觸發其他網絡請求。我不知道爲什麼會發生這種情況。任何人都可以指出任何潛在的原因嗎?

謝謝!

回答

0

發生這種情況時,請確保查看例外報告的查看詳細信息部分。可能是您的服務拒絕連接,或者傳遞的數據無效。 NotSupported是一個非常普遍的例外,涵蓋了許多可能的情況。

0

類似的question以前已被詢問過。如果你看一下原來的海報加入answer的評論,他聲稱用

request.BeginGetResponse(MyService_Completed, request); 
更換

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

已經解決了這個問題