diff --git a/samples/NativeAOT/MainApplication.cs b/samples/NativeAOT/MainApplication.cs index e3f2c6f546f..32b2a3a0dd0 100644 --- a/samples/NativeAOT/MainApplication.cs +++ b/samples/NativeAOT/MainApplication.cs @@ -19,5 +19,12 @@ public override void OnCreate () Log.Debug ("NativeAOT", "Application.OnCreate()"); base.OnCreate (); + + AppDomain.CurrentDomain.UnhandledException += (sender, e) => { + Console.WriteLine ("AppDomain.UnhandledException!"); + Console.WriteLine ($" sender: {sender} [{sender != null} {sender?.GetType ()}]"); + Console.WriteLine ($" e.IsTerminating: {e.IsTerminating}"); + Console.WriteLine ($" e.ExceptionObject: {e.ExceptionObject}"); + }; } } diff --git a/src/Microsoft.Android.Runtime.NativeAOT/UncaughtExceptionMarshaler.cs b/src/Microsoft.Android.Runtime.NativeAOT/UncaughtExceptionMarshaler.cs index 82eef4264a9..cef69999d88 100644 --- a/src/Microsoft.Android.Runtime.NativeAOT/UncaughtExceptionMarshaler.cs +++ b/src/Microsoft.Android.Runtime.NativeAOT/UncaughtExceptionMarshaler.cs @@ -1,3 +1,5 @@ +using System.Runtime.ExceptionServices; + using Java.Interop; namespace Microsoft.Android.Runtime; @@ -12,8 +14,7 @@ public void UncaughtException (Java.Lang.Thread thread, Java.Lang.Throwable exce AndroidLog.Print (AndroidLogLevel.Fatal, "DOTNET", $"FATAL UNHANDLED EXCEPTION: {e}"); - // TODO: https://github.com/dotnet/runtime/issues/102730 - // ExceptionHandling.RaiseUnhandledExceptionEvent(e); + ExceptionHandling.RaiseAppDomainUnhandledExceptionEvent(e); OriginalHandler?.UncaughtException (thread, exception); }