我通過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:
這是推動我絕對堅果,因爲異常是沒有指出任何有用的東西。我已經在提琴手中啓用了「流媒體」選項,但我沒有看到任何流量/錯誤。
請幫忙!