2

我正在使用以下绑定将 Flurry Analytics 集成到我的 Xamarin/MonoTouch iOS 应用程序中: https ://github.com/mono/monotouch-bindings/tree/master/FlurryAnalytics

现在,我想使用 Flurry Analytic 的错误记录:

void LogError (string errorID, string message, NSException exception);

我在我的 AppDelegate 中使用此代码捕获异常:

AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => { /**/ };

但是,据我所知,Xamarin/MonoTouch 已将所有 NSExceptions 转换为 System.Exception。

System.Exception 可以转换回 NSException 以便我可以在 LogError 例程中使用它吗?

或者是否可以在 Xamarin/MonoTouch 项目中捕获 NSExceptions?

4

1 回答 1

1

为什么不在 AppDelegate 类中使用 UncaughtExceptionHandler 呢?他们在您提到的 github 页面上有一个示例。

static void UncaughtExceptionHandler(IntPtr handle)
        {

            var exception = new NSException(handle);
            FA.Flurry.LogError("3584", exception.Reason, exception);

            Console.WriteLine(@"Got an exception...{0} -- {1}", exception.Name, exception.Reason);
        }

https://github.com/mono/monotouch-bindings/blob/master/FlurryAnalytics/sample/Xamarin.FlurryAnalyticsSample/AppDelegate.cs

编辑:该示例还显示了如何在AnalyticsViewController.cs中记录 System.Exception

于 2013-07-17T05:37:33.737 回答