1

I have a Windows Phone 7 application built with silverlight. This application has been deployed. I've noticed in the log files that occasionally, my user's actions throw a "NotSupportedException". I have not been able to produce this. However, because of my logs, I know that it is happening in the Execute method shown here:

public void Execute()
{
  try
  {
    // 1. Build the query
   string serviceUrl = GetServiceUrl;

    // 2. Asynchronously execute the query using HttpWebRequest
    WebRequest request = HttpWebRequest.Create(serviceUrl);
    request.BeginGetResponse(new AsyncCallback(ServiceRequest_Completed), request);
  }   catch (Exception ex)
  {
    LogException(ex, "1");
  }
}


private void ServiceRequest_Completed(IAsyncResult result)
{
  try
  {
    // 1. Get the response from the service call
    WebRequest request = (WebRequest)(result.AsyncState);
    WebResponse response = request.EndGetResponse(result);

    // 2. Do stuff with response
  } 
  catch (Exception ex)
  {
    LogException(ex, "2");
  }
}

I know it is happening in the Execute method because the "1" is written in the log file instead of the "2" My question is, what would cause this? I looked at the MSDN documentation and it looks like I'm doing what I should be doing. Like I said, I can't reproduce it locally. But I do know that it is happening regularly by different users because of the log files.

bkaid
  • 51,465
  • 22
  • 112
  • 128
Villager
  • 6,569
  • 22
  • 65
  • 87
  • What details are in the exception that you are logging. Do they not tell you what the cause is? What line is causing the error? What is in the getter of `GetServiceUrl`? – Matt Lacey Mar 25 '11 at 12:51

1 Answers1

0

There is a previous question with a very similar title - https://stackoverflow.com/questions/4053197/httpwebrequest-leads-me-to-system-notsupportedexception

The answer to that problem seems to have been using ServiceRequest_Completed instead of new AsyncCallback(ServiceRequest_Completed)

Community
  • 1
  • 1
Stuart
  • 66,722
  • 7
  • 114
  • 165