ARTICLE AD BOX
After porting my NET9 MAUI application to NET 10 MAUI, I experience a few issues in the Android version.
I updated all the packages I could with the latest version or the preview version but there are some alerts I don't know know why.
The real issue is that the application is working fine in Debug in the emulators and real devices. When the app is in Release mode, I deploy the app on device (emulator or physical device). I can see the app starts but then saddenly crashes. In the App.xaml.cs, I added
AppDomain.CurrentDomain.FirstChanceException += (sender, e) => { // Log the exception or handle it as needed Console.WriteLine($"First chance exception: {e.Exception.Message}"); };and the error I can get is
12-19 12:51:27.389 I/DOTNET (17181): First chance exception: InvalidCast_IConvertible
but I don't know where this error is coming from. Using CoPilot, it suggested to change this code
AppDomain.CurrentDomain.FirstChanceException += (sender, e) => { // Skip logging known internal SDK exceptions that are handled internally if (e.Exception is InvalidCastException && e.Exception.Message.Contains("InvalidCast_IConvertible")) { // This is a known issue with AppCenter/AdMob SDKs in Release mode // The exception is caught internally and doesn't affect the app return; } // Log the exception or handle it as needed Console.WriteLine($"[Error] First chance exception: {e.Exception.Message}"); };I'm not really sure this is a good solution because this hides the real problem in other part of the code. When I run the application from Visual Studio in Release to a physical device, the app crashes as usual. If I open the deployed app on the device, the app is working.
Can you recommend how to avoid this crashes? Is this approach correct? How can I find where the error is coming from?

