我正在嘗試使用新的System.Net.Http位來構建一個簡單的HTTP客戶端來與基於HTTP的API進行通信。我用Nuget(Microsoft.AspNet.WebApi.Client.4.0.20505.0)安裝了這些位。使用WebRequestHandler的ServerCertificateValidationCallback時MissingMethodException?
我需要接受一些自簽名證書,所以我試圖設置WebRequestHandler類的ServerCertificateValidationCallback屬性。下面是說明我遇到的問題兩線測試:
[Test]
public void CanRunDummyTest() {
var handler = new WebRequestHandler();
handler.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
}
但它拋出:
CanRunDummyTest : FailedSystem.MissingMethodException :
Method not found: 'Void System.Net.Http.WebRequestHandler.set_ServerCertificateValidationCallback(System.Net.Security.RemoteCertificateValidationCallback)'
at AxlTests.RawAxlTests.CanRunDummyTest()
看來類的設置屬性不落實?有任何想法嗎?
Aha ...是的,我忽略提及,我正在運行VS 2010和.NET 4.0。感謝您理清我;-) – 2012-07-13 21:43:26
當我嘗試使用這個,但只在Azure服務器上有NotImplementedException。我的項目設置爲.Net 4.你是如何繞過這個的? – NER1808 2012-12-06 12:49:14