Xamarin.Forms httpclient throws System.Net.Security.Native assembly:<unknown assembly> type:<unknown type> member:(null)

62 Views Asked by At

If you have something like

private HttpClient _httpClient;
private CredentialCache _credentialCache;
{
            _credentialCache = new CredentialCache
            {
                { new Uri(_connectionConfiguration.Server), "Negotiate", new     NetworkCredential(_connectionConfiguration.Username, _connectionConfiguration.Password, _connectionConfiguration.Domain) },
                { new Uri(_connectionConfiguration.Server), "NTLM", new NetworkCredential(_connectionConfiguration.Username, _connectionConfiguration.Password, _connectionConfiguration.Domain) }
            };
            var androidClientHandler = new AndroidClientHandler() { Credentials = _credentialCache };
            //var httpClientHandler = new HttpClientHandler() { Credentials = _credentialCache };
            _httpClient = new HttpClient((HttpMessageHandler)androidClientHandler);
}
var _ = _httpClient.GetAsync(_connectionConfiguration.Server).Result;

-> use of //line with HttpClientHandler leads to System.ComponentModel.Win32Exception: One or more errors occurred. (System.Net.Security.Native assembly: type: member:(null))

Use of AndroidClientHandler SOLVES the problem

0

There are 0 best solutions below