-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MacCatalyst currently doesn't surface unhandled exceptions in user code so we should help MAUI users out #7176
Comments
We can add a bit of logic in the platform folder to wire up the event: class Program
{
static void Main()
{
#if DEBUG
Runtime.MarshalManagedException += (sender, e) => {
Debugger.Break();
};
#endif
}
} Not sure if it is best in Program.cs or the app delegate... @rolfbjarne where is the best place for an event like this? |
IMHO the sooner the better, so first thing in Main |
Related to xamarin/xamarin-macios#15037 |
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process. |
If anyone else is trying to work around this issue with uncaught exceptions in MacCatalyst code, I've got the following added to my #if DEBUG
// https://github.com/dotnet/maui/issues/7176
Runtime.MarshalManagedException += (_, a) => {
Console.WriteLine("Uncaught MacCatalyst Exception");
Console.WriteLine(a.Exception.ToString());
Debugger.Break();
Environment.Exit(-1);
};
#endif It will fire the debugger but it isn't much use, the printed stack trace is however. Hopefully this is helpful to someone else. |
It might work to set the var defs = new NSDictionary ((NSString) "NSApplicationCrashOnExceptions", NSValue.FromBoolean (true));
NSUserDefaults.StandardUserDefaults.RegisterDefaults (defs); |
Verified this issue with VSM 17.6.7 (build 417). Can repro this issue. |
…ion is marshalled. This means the debugger will be notified of all marshalled exceptions, and consider them unhandled (and break the debugged app into the debugger). There's no corresponding change for CoreCLR, because we have no configuration where we can attach a debugger to a CoreCLR-based app (VSCode doesn't support macOS, and NativeAOT doesn't support debugging). Partial fix for #15037. Fixes dotnet/maui#7176. Ref: dotnet/android#6106
Currently
AppKit
will handle any exception thrown from user code and won't surface it to the user.The following code
Will just throw an NRE with no indication to the user that an NRE has occurred
We should wire into the following method
And break when a debugger is attached to help the user (and us) be more successful.
We should also wire up our UI Tests so that any exceptions that make it here are surfaced.
Depends on
The text was updated successfully, but these errors were encountered: