Skip to content

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

Description

@shantimohan

Where did you get the code?

Describe the bug
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.

To Reproduce
Steps to reproduce the behavior:

  1. After successful login into OneDrive service...
  2. The error occurring is: System.TypeInitializationException Message=The type initializer for 'System.Text.Json.JsonSerializer' threw an exception
  3. This error is produced when executing the code: IDriveItemChildrenCollectionPage files = await OdGraphClient.Me.Drive.Root.Children.Request().GetAsync();

Expected behavior
When the code mentioned in Step 3 above, it should return list of objects at the root directory.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: iOS [e.g. iOS]
  • VS 2019 Version 16.11.2
  • Xamarin.Forms version
  • Xamarin.iOS Version 14.20.0.25

Dependency versions

  • Authentication library (MSAL, etc.) version: Microsoft.Identity.Client Version 4.36.0
  • Graph library (Graph SDK, REST library, etc.) version: Microsoft.Graph 4.4.0

Additional context
This occurs only in iOS and not in Android.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions