I have a piece of code that uses System.Net.Http Library. and when ever I create new instance of System.Net.Http.HttpClientHandler an Exception occures , For Example:
private async void btnTest_Click(object sender, RoutedEventArgs e)
{
var handler = new System.Net.Http.HttpClientHandler();
//default constructor does the same thing :this(new HttpClientHandler())
var client = new System.Net.Http.HttpClient(handler);
var resp = (await client.GetAsync("any url"));
var content = resp.Content;
}
and the Exception is :
System.TypeLoadException: Could not load type
'System.Security.Authentication.SslProtocols' from assembly
'System.Net.Primitives, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'.
at System.Net.Http.HttpClientHandler..ctor()
at MyApp.MainWindow.<btnTest_Click>d__0.MoveNext() in c:\MyApp\MainWindow.xaml.cs:line 30
I tested the code on win 7, no exception thrown, but whatever i tried on win8.1 the same exception was thrown.