I am really stuck on this. I upgraded my Xamarin Forms project to .NET Standard from PCL, and this code below no longer works on Android. I have my Android settings for HttpClient implementation of Android and SSL/TLS implementation to Native TLS 1.2+. In particular, when I am debugging, and I try to step over the line with httpClient.GetStringAsync … it blows up with Frame not in module (The current stack frame was not found in a loaded module. Source cannot be shown for this location). And it returns back to the caller. The try / catch does not catch and error. I can step thru this code fine in UWP/ iOS. I have been stuck on this for a while now. Any ideas would be greatly appreciated. I have tried wrapping the httpclient with a using statement and get the same results too. All of my NuGet packages are up to date. I am running on actual device running Android version 8.1.0, not emulator, to an actual service, not localhost.
Here is my code:
private async Task<List<string>> GetVideoIdsFromPlaylistAsync()
{
var httpClient = new HttpClient();
var videoIds = new List<string>();
try
{
var json = await httpClient.GetStringAsync(apiUrlForPlaylist).ConfigureAwait(false);
JObject response = JsonConvert.DeserializeObject<dynamic>(json);
var items = response.Value<JArray>("items");
foreach (var item in items)
{
videoIds.Add(item.Value<JObject>("contentDetails")?.Value<string>("videoId"));
};
YoutubeItems = await GetVideosDetailsAsync(videoIds);
}
catch (Exception ex)
{
Console.WriteLine(@" Error {0}", ex.Message);
Console.WriteLine(@" Error {0}", ex.InnerException?.Message);
}
return videoIds;
}