如何在AppCenter SDK for C#中为TrackError注册事件处理程序?

问题描述 投票:1回答:2

我在调用TrackError之前注册了事件处理程序,但从未调用过它们。是的,事件发生了,因为错误出现在AppCenter中。

//On loading app
Crashes.SentErrorReport += (sender, args) => { System.Diagnostics.Process.GetCurrentProcess().Kill(); };
Crashes.FailedToSendErrorReport += (sender, args) => { System.Diagnostics.Process.GetCurrentProcess().Kill(); };

AppCenter.Start("{App secret here}" +
       "android={App secret here}" +
       "ios={App secret here}",
       typeof(Analytics), typeof(Crashes));

//Elsewhere in the app
Crashes.TrackError(exception, comments, attachments);

遵循此文档:https://docs.microsoft.com/en-us/appcenter/sdk/crashes/xamarin

c# xamarin uwp visual-studio-app-center
2个回答
0
投票

它们从未被调用,因为这两个事件处理程序不再在Page / Fragment / UIViewController的范围内。 (Xamarin.Forms中的页面,Xamarin.Android中的片段,Xamarin.iOS中的UIViewController)

您需要在新页面中重新分配事件处理程序。也许在所有其他页面继承的BasePage中定义它。


0
投票

[App Center中处理的异常又称为错误(开发人员手动使用Crashes.trackError报告的错误)不支持此功能。

该事件仅用于崩溃(导致应用程序退出未处理的异常)引起的。重新启动崩溃的进程后,也会调用这些事件。

© www.soinside.com 2019 - 2024. All rights reserved.