问题描述
限时送ChatGPT账号..我有一个用 silverlight 构建的 Windows Phone 7 应用程序.此应用程序已部署.我在日志文件中注意到,我的用户的操作偶尔会抛出NotSupportedException".我一直无法生产这个.但是,由于我的日志,我知道它发生在此处显示的 Execute 方法中:
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");
}
}
我知道它发生在 Execute 方法中,因为日志文件中写入的是1"而不是2".我的问题是,什么会导致这种情况?我查看了 MSDN 文档 看起来我正在做我应该做的事情.就像我说的,我无法在本地复制它.但我确实知道由于日志文件,它经常由不同的用户发生.
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.
推荐答案
之前有一个标题非常相似的问题 - https://stackoverflow/questions/4053197/httpwebrequest-leads-me-to-system-notsupportedexception
There is a previous question with a very similar title - https://stackoverflow/questions/4053197/httpwebrequest-leads-me-to-system-notsupportedexception
这个问题的答案似乎是使用 ServiceRequest_Completed
而不是 new AsyncCallback(ServiceRequest_Completed)
The answer to that problem seems to have been using ServiceRequest_Completed
instead of new AsyncCallback(ServiceRequest_Completed)
这篇关于Windows Phone 7 上 HttpWebRequest 中的 NotSupportedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论