Xamarin.ios 在ios xamarin项目中显示uiAlert,但未显示异常

Xamarin.ios 在ios xamarin项目中显示uiAlert,但未显示异常,xamarin.ios,xamarin.forms,Xamarin.ios,Xamarin.forms,我试图在出现异常并冒泡到iOS项目时显示警报。Main 现在让我们假设在程序中的某个地方有一个“objectvariable not set exception” 它会跳转到MyApp.IOS项目,但不会弹出任何UI警报 public class Application { static void Main(string[] args) { try {

我试图在出现异常并冒泡到iOS项目时显示警报。Main

现在让我们假设在程序中的某个地方有一个“objectvariable not set exception”

它会跳转到MyApp.IOS项目,但不会弹出任何UI警报

        public class Application
        {
            static void Main(string[] args)
            {
                try
                {
                    UIApplication.Main(args, null, "AppDelegate");
                }

                catch (Exception ex)
                {
                    Task.Run(() =>
                    {
                        Device.BeginInvokeOnMainThread(() => {
                            ShowAlert("MyTitle", ex.ToString(), UIApplication.SharedApplication.KeyWindow.RootViewController); 
                        });
                    });

                }

            }
            public static UIAlertController ShowAlert(string title, string description, UIViewController controller)
            {
                UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);

                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (action) => { }));

                controller.PresentViewController(alert, true, null);

                return alert;
            }
        }

知道我遗漏了什么吗?

不可能捕捉错误并显示警报。检查有关本机崩溃的信息。并检查日志文件


无法捕获错误并显示警报。检查有关本机崩溃的信息。并检查日志文件


发生异常后,应用程序是否仍在运行?因为在发生异常后,应用程序似乎已死亡。在我处理警报后,应用程序已死亡。如果是这种情况,除了日志记录之外,是否有方法向用户显示消息或太晚?在发生异常后,应用程序是否仍在运行?因为在发生异常后,应用程序似乎已死亡。在我处理警报后,应用程序已死亡。如果是这种情况,除了日志记录之外,是否有一种向用户显示消息的方式,还是太晚了?