如何在AppCenter SDK for C#中注册TrackError的事件处理程序?
我在调用TrackError之前注册了事件处理程序,但从未调用它们。是的,事件发生是因为错误出现在AppCenter中如何在AppCenter SDK for C#中注册TrackError的事件处理程序?,c#,xamarin,uwp,visual-studio-app-center,C#,Xamarin,Uwp,Visual Studio App Center,我在调用TrackError之前注册了事件处理程序,但从未调用它们。是的,事件发生是因为错误出现在AppCenter中 //On loading app Crashes.SentErrorReport += (sender, args) => { System.Diagnostics.Process.GetCurrentProcess().Kill(); }; Crashes.FailedToSendErrorReport += (sender, args) => { System.
//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);
遵循此文档:永远不会调用它们,因为这两个事件处理程序不再在页面/Fragment/UIViewController的范围内。(Xamarin.Forms中的页面,Xamarin.Android中的片段,Xamarin.iOS中的UIViewController)
您需要在新页面中重新分配事件处理程序。可能在所有其他页面继承的BasePage/BaseViewModel中定义它。对于App Center中已处理的异常或错误(开发人员使用
崩溃.trackError
手动报告的异常),不支持此功能
事件仅在崩溃时触发(导致应用程序退出的未处理异常)。这些事件也会在崩溃进程重新启动后调用。启动AppCenter后是否尝试过设置它们?@Jason Yes。然后我仔细阅读了文档,看到了文档中说在调用AppCenter.Start.之前必须注册的位置,然后每次调用AppCenter.Start?没有意义。不,伙计,你只需调用AppCenter.Start一次,但你调用这个
crasks.SentErrorReport+=(发送方,args)=>{System.Diagnostics.Process.GetCurrentProcess().Kill();}代码>crasks.FailedToSendErrorReport+=(发送方,参数)=>{System.Diagnostics.Process.GetCurrentProcess().Kill();}代码>每次您是否仅为UWP编码?或者它不适用于Android和iOS?谢谢@Guillaume Perrot。文件中是否明确说明了这一点?我有没有忽略这一点?医生只是提到这是为了“崩溃日志”。我们没有坚持崩溃和处理错误之间的区别,所以我可以研究提交一个bug来澄清这一区别。“已处理错误”部分后来作为增量更改添加到页面末尾的产品中。