Aspose.Email .Net - ListMessages method from MS Graph Client failing on Mac OS

I am trying to access outlook/hotmail mails through MS Graph API using Aspose.Email.
Every thing works fine in debug mode - I am able to get access token, able to get mail folder’s list and messages but in release mode ListMessages method is failing.

Exception is -
01-10-2024 18:21:00 System.TypeLoadException: Cannot load type ‘System.String, netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’.
at a.fu (System.Int32 d, v v, System.Boolean& c, System.Boolean t) [0x00217] in <4e5cf0be310a403f7c76830167849157>:0
at a.KE (System.Int32 d, System.Boolean v) [0x00032] in <4e5cf0be310a403f7c76830167849157>:0
at a.tu () [0x0002b] in <4e5cf0be310a403f7c76830167849157>:0
at a.FE (System.Object[] d, System.Type[] v, System.Type[] c, System.Object[] t) [0x00035] in <4e5cf0be310a403f7c76830167849157>:0
at a.Su (System.IO.Stream d, System.String v, System.Object[] c, System.Type[] t, System.Type[] n, System.Object[] B) [0x0000f] in <4e5cf0be310a403f7c76830167849157>:0
at a.ru (System.IO.Stream d, System.String v, System.Object[] c) [0x00000] in <4e5cf0be310a403f7c76830167849157>:0
at OP.TqWcAuccfZvrQ0Zl9FxbuHiZohM8Mcaaģܣ () [0x0000a] in <4e5cf0be310a403f7c76830167849157>:0
at vk.BWiFX (System.String d) [0x00120] in <4e5cf0be310a403f7c76830167849157>:0
at mW[d].B (System.Text.StringBuilder d, jv v) [0x00442] in <4e5cf0be310a403f7c76830167849157>:0
at mW[d].mWiFn (System.Text.StringBuilder d, jv v) [0x00000] in <4e5cf0be310a403f7c76830167849157>:0
at OW[d].mWiFn (System.Text.StringBuilder d, jv v) [0x00000] in <4e5cf0be310a403f7c76830167849157>:0
at mW[d].mWiFc () [0x0001a] in <4e5cf0be310a403f7c76830167849157>:0
at dW.ListMessages (System.String d) [0x00007] in <4e5cf0be310a403f7c76830167849157>:0
at MacMBoxExport.ViewController.bkThreadTab4Next_DoWorkO (System.Object sender, System.ComponentModel.DoWorkEventArgs eArgs) [0x02045] in :0 exception caught in VC.1.042.002

Aspose.Email .Net Version 24.9.0
OS: Mac Ventura 13.4
Language: C# on Visual studio 2022 for Mac
Xcode: 14.3.1
Project Type : Xamarin Cocoa App

Test project link : Unique Download Link | WeTransfer

Hello @sangapankaj ,

Welcome to our community!

It seems like the issue you are encountering is related to a missing or incorrect assembly reference when switching from debug mode to release mode. Specifically, the error mentions a System.TypeLoadException, which usually occurs when a type or assembly expected at runtime is not available or loaded incorrectly.

If you have other questions related to the issue, feel free to ask.

Can you point out , Which library is missing?
I have added Aspose.Email through Nuget package. What else is needed?

@sangapankaj,

It seems, the error you’re encountering, does not appear to be related to the Aspose.Email library.

  • Since everything works fine in debug mode, it’s more indicative of a configuration issue in release mode. Xamarin’s release build process often behaves differently (due to optimizations like the linker, AOT, etc.), which can lead to problems with dependencies if they aren’t properly referenced or included in the build.
  • The error mentions System.String, netstandard, Version=2.0.0.0, suggesting that the netstandard library or one of its dependencies might be missing or incorrectly referenced in the release build.

The problem is more likely to be related to how Xamarin is handling dependencies and linking them in release mode.

Try to check few points:

  • In the release configuration, you are using LinkMode=“Full”, which could be stripping away required assemblies or components related to the ListMessages method or dependencies. Try changing LinkMode to None in the release configuration or adjust it to LinkMode=“SdkOnly” to see if this resolves the issue.

  • The release mode includes the Mono runtime (IncludeMonoRuntime=true), which can affect the runtime behavior. Ensure that the correct assemblies are included and not stripped during the linking process.

  • In release mode, optimizations are turned on (Optimize=true). Try disabling this temporarily to see if it impacts the behavior.

Thanks for help.
Changing LinkMode to None, worked for me.

You’re welcome! If you need further assistance, feel free to contact us!