我有一个可移植的类库(支持.NET4.03,Silverlight 5,WinPhone 8和WinStore的配置文件147),它使用HttpClient进行HTTP调用。除了Silverlight 5之外,该库在所有平台上都能正常工作。
当从SL5应用程序使用库时,尝试使用GET谓词调用SendAsync方法会导致NotImplementedException:
{System.NotImplementedException:未实现方法或操作。 在System.Net.Browser.ClientHttpWebRequest.set_AllowAutoRedirect(布尔值)}
我没有调用这样的方法(它暴露在HttpClientHandler类上)。我设置了几个HTTP标头,但它们似乎与此问题无关。
这里有什么不妥?
UPDATE 以下是异常堆栈跟踪:
System.Windows.dll!System.Net.Browser.ClientHttpWebRequest.AllowAutoRedirect.set(bool value) + 0x3d bytes
System.Net.Http!System.Lightup.TryCall<System.Net.HttpWebRequest,bool>(ref System.Delegate storage, System.Net.HttpWebRequest instance, string methodName, bool parameter) + 0xb9 bytes
System.Net.Http!System.Lightup.TrySet<System.Net.HttpWebRequest,bool>(ref System.Delegate storage, System.Net.HttpWebRequest instance, string propertyName, bool value) + 0xa1 bytes
System.Net.Http!System.Net.HttpWebRequestLightup.TrySetAllowAutoRedirect(System.Net.HttpWebRequest instance, bool value) + 0x47 bytes
System.Net.Http!System.Net.Http.HttpWebRequest.AllowAutoRedirect.set(bool value) + 0x58 bytes
System.Net.Http!System.Net.Http.HttpClientHandler.SetDefaultOptions(System.Net.Http.HttpWebRequest webRequest) + 0x3e bytes
System.Net.Http!System.Net.Http.HttpClientHandler.CreateAndPrepareWebRequest(System.Net.Http.HttpRequestMessage request) + 0x109 bytes
System.Net.Http!System.Net.Http.HttpClientHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) + 0x1af bytes
System.Net.Http!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) + 0x10e bytes
System.Net.Http!System.Net.Http.HttpClient.SendAsync(System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) + 0x1f4 bytes
System.Net.Http!System.Net.Http.HttpClient.SendAsync(System.Net.Http.HttpRequestMessage request) + 0x61 bytes
Simple.OData.Client.Core!Simple.OData.Client.RequestRunnerBase.ExecuteRequestAsync(Simple.OData.Client.HttpRequest request)第49行+ 0x1c字节C# Simple.OData.Client.Core!Simple.OData.Client.ODataClient.GetSchemaAsStringAsync(string urlBase,System.Net.ICredentials credentials)第23行+ 0x17字节C# Simple.OData.Client.Core!Simple.OData.Client.Schema.FromUrl()第233行+ 0x1e字节C# [恢复异步方法] System.Threading.Tasks!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Startb__10&gt;(ref Simple.OData.Client.Schema..b_ 10 stateMachine)+ 0xbd bytes
System.Threading.Tasks!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Startb__10&gt;(ref Simple.OData.Client.Schema..b _10 stateMachine)+ 0x46 bytes
Simple.OData.Client.Core!Simple.OData.Client.Schema.FromUrl.AnonymousMethod__10()+ 0x96 bytes
Simple.OData.Client.Core!Simple.OData.Client.Schema.ResolveAsync()第52行+ 0x1c字节C# Simple.OData.Client.Core!Simple.OData.Client.ODataClient.FindEntriesAsync(string commandText)第60行+ 0xe字节C# Simple.OData.Client.Tests.SL5App!Simple.OData.Client.Tests.ClientTests.FindEntries()第24行+ 0x19字节C# Simple.OData.Client.Tests.SL5App!Simple.OData.Client.Tests.SL5App.MainPage.FindEntries()第34行+ 0x11字节C# Simple.OData.Client.Tests.SL5App!Simple.OData.Client.Tests.SL5App.MainPage.buttonFindEntries_Click(object sender,System.Windows.RoutedEventArgs e)第25行+ 0x8字节C# System.Windows.dll!System.Windows.Controls.Primitives.ButtonBase.OnClick()+ 0x3d bytes System.Windows.dll!System.Windows.Controls.Button.OnClick()+ 0x44 bytes
System.Windows.dll!System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e)+ 0x89 bytes
System.Windows.dll!System.Windows.Controls.Control.OnMouseLeftButtonUp(System.Windows.Controls.Control ctrl,System.EventArgs e)+ 0x2a bytes
System.Windows.dll!MS.Internal.JoltHelper.FireEvent(System.IntPtr unmanagedObj,System.IntPtr unmanagedObjArgs,int argsTypeIndex,int actualArgsTypeIndex,string eventName,uint flags)+ 0x28f bytes [Appdomain Transition]