我通过http调用REST服务,返回一个流作为响应。 我的客户端代码看起来像这样:Silverlight 4 HttpWebRequest抛出ProtocolViolationException
Uri uri = new Uri(remoteAddress);
var webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.Method = "GET";
webRequest.ContentType = "multipart/mixed";
webRequest.BeginGetResponse(responseResult =>
{
HttpWebResponse response = (HttpWebResponse)webRequest.EndGetResponse(responseResult);
this.messages = ParseResponse(response);
Complete(false);
}, null);
我得到这条线以下错误:
HttpWebResponse response = (HttpWebResponse)webRequest.EndGetResponse(responseResult);
System.Net.ProtocolViolationException是由用户代码未处理 消息=操作无效由于对象的当前状态。 堆栈跟踪: 在System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,对象状态) 在System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult的asyncResult) 在LaharSubProxy.SubscribeAsyncResult`1。 <> c__DisplayClass1.b__0(IAsyncResult responseResult) at System.Net.Browser.BrowserHttpWebRequest。 <> c__DisplayClassd.b__b(对象STATE2) 在System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(对象状态) 在System.Threading.ExecutionContext.Run(的ExecutionContext的ExecutionContext,ContextCallback回调,对象的状态,布尔ignoreSyncCtx) 在的System.Threading。 QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() 在System.Threading.ThreadPoolWorkQueue.Dispatch() 在System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() 的InnerException:
这是推动我绝对坚果,因为异常是没有指出任何有用的东西。我已经在提琴手中启用了“流媒体”选项,但我没有看到任何流量/错误。
请帮忙!