Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

System.Net.Http not found

$
0
0

Visual Studio 2015
Xamarin 3.9.289
Xamarin.Android 4.20.0.34

I have a basic almost hello world type app that is making a rest call with basic authentication.

This is the most relevant error message I see in the debug output window:

02-09 21:50:38.362 D/Mono ( 2514): AOT module 'System.Net.Http.dll.so' not found: dlopen failed: library "/data/data/ATD.Droid/lib/System.Net.Http.dll.so" not found

The error occurs when I step over the line below await response.Content.ReadAsStringAsync();

Any ideas on what might be causing this problem. I have reference system.net and system.net.http in the project.

Thanks
Brady

    public static async Task<T> GetAsync<T>(this HttpClient client, string url)
    {
        try {
            var httpRequest = new HttpRequestMessage(new HttpMethod("GET"), url);

            client.Timeout = TimeSpan.FromSeconds(30);

            string username = "consportapi";
            string password = "64ea2b32-d623-4e99-8683-7033ea4c70c5";
            string t = string.Format("{0}:{1}", username, password);
            byte[] bytes = Encoding.UTF8.GetBytes(string.Format("{0}:{1}", username, password));
            string b64t = Convert.ToBase64String(bytes);
            //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(string.Format("basic {0}", b64t));
            httpRequest.Headers.Add("Authorization", b64t);
            var response = await client.SendAsync(httpRequest);

            var jsonString = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject<T>(jsonString);

            return result;
        } catch (Exception ex)
        {
            Debug.WriteLine(ex.Message);
            return default(T);
        }
    }

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>