question

ShantimohanElchuri-3006 avatar image
0 Votes"
ShantimohanElchuri-3006 asked saldana-msft edited

OneDrive Graph Client throwing System.TypeInitializationException in Xamarin.iOS project only

This was working till few days back. It appears one of the recent updates to Xamain.iOS has broken it.

I have implemented OneDrive client in my project as per Build Xamarin apps with Microsoft Graph.

This is a Xamarin Forms project. Installed Microsoft.Graph only in the common project and installed Microsoft.Identity.Client in all projects.

After successful login into OneDrive Service, it is throwing the following exception:

System.TypeInitializationException
Message=The type initializer for 'System.Text.Json.JsonSerializer' threw an exception.

It is failing executing the following code:

         IDriveItemChildrenCollectionPage files = null;
         files = await OdGraphClient.Me.Drive.Root
             .Children
             .Request()
             .GetAsync();






dotnet-xamarinmicrosoft-graph-sdkmicrosoft-graph-files
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bumping up...any answers or workarounds?

0 Votes 0 ·
ShantimohanElchuri-3006 avatar image
0 Votes"
ShantimohanElchuri-3006 answered

@Deva-MSFT The actual resolution was found in the accepted answer of jsonserializer-throws-exception-in-xamarinios.html

Added the following lines to iOS project file in the ItemGroup containing Package References:

<PackageReference Include="System.Memory" Version="4.5.4">
<IncludeAssets>none</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Buffers" Version="4.5.1">
<IncludeAssets>none</IncludeAssets>
</PackageReference>



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Deva-MSFT avatar image
0 Votes"
Deva-MSFT answered ShantimohanElchuri-8757 commented

I would suggest you to get the latest pull and see if you can repro the issue. If yes, then report the issue at the project issues list.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I updated the NuGet packages. Now I am using:

  1. Microsoft.Identity.Client Version 4.36.0

  2. Microsoft.Graph Version 4.4.0


Even now still the error is occurring. Submitted a bug report at the project issues list link provided.

0 Votes 0 ·

Posted the issue on Github as isssue 1127

I was asked to check issue 1124

That worked.


0 Votes 0 ·