2016-10-25 124 views
2

我的应用程序意外崩溃了,我没听清楚是什么任何异常......我已经注册的处理程序:xamarin.mac应用程序崩溃报告

static void Main (string [] args) 
     { 
      NSApplication.Init(); 
      NSApplication.Main (args); 

      AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException; 
     } 


     static void HandleUnhandledException (object sender, UnhandledExceptionEventArgs e) 
     { 
      //Log the exception... 
      FileHelper.CreateLogFile ("app crash", e.ExceptionObject.ToString()); 
     } 

但它不叫。

而且,我看不到里面的任何报告:

〜/图书馆/日志/ DiagnosticReports

有没有办法看到我的应用程序的崩溃报告?

回答

2

AppDomain.CurrentDomain.UnhandledException仅当您有一个管理的异常发生时才会触发整个堆栈。但是,如果您在本机代码中崩溃,或者在本机代码中出现NSException,或者在从本机代码中调用时抛出托管的异常,则它可能不会执行您想要的任何操作。

试试这个:

ObjCRuntime.Runtime.MarshalManagedException += (sender, args) => 
{ 
    Console.WriteLine (args.Exception); 
}; 

您也可以考虑对MMP编组的ObjectiveC的例外和元帅管理的例外(https://github.com/xamarin/xamarin-macios/blob/master/tools/common/Driver.cs#L24)这些选项。

相关问题