microsoftgraph / msgraph-sample-maui

This sample demonstrates how to use the Microsoft Graph .NET SDK to access data in Office 365 from .NET MAUI apps.
MIT License
31 stars 15 forks source link

Android.OS.NetworkOnMainThreadException, following this sample #123

Closed RollsChris closed 3 months ago

RollsChris commented 8 months ago

Hi, I am getting Android.OS.NetworkOnMainThreadException when trying to retrieve the users photo with this code:

    _userPhoto = await graphClient.Me
       .Photo
       .Content
       .GetAsync();

i cant figure out why any tips?

this code runs before just fine:

   _user = await graphClient.Me.GetAsync(
       requestConfiguration =>
       {
           requestConfiguration.QueryParameters.Select =
               new[] { "displayName", "mail" };
       });
jasonjoh commented 8 months ago

Interesting. I found this issue: https://github.com/xamarin/xamarin-android/issues/5264. From reading through the comments, using .ConfigureAwait instead of await fixed the problem.

RollsChris commented 8 months ago

sorry just seen this, ill try that thanks ;)

microsoft-github-policy-service[bot] commented 5 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.