gpt4 book ai didi

ios - 在 Xamarin 中捕获 EXC_CRASH (SIGABRT) 异常

转载 作者:行者123 更新时间:2023-11-28 23:28:36 25 4
gpt4 key购买 nike

我为 Xamarin.Forms 编写了自定义异常处理程序,我注意到并非所有异常都被捕获。例如。这个不是(取自 Xcode > 设备和模拟器中的设备日志):

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0

Application Specific Information:
abort() called

Filtered syslog:
None found

Thread 0 name: tid_303 Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000180d3d2e0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x0000000180ede288 pthread_kill$VARIANT$mp + 376
2 libsystem_c.dylib 0x0000000180cabdb0 __abort + 152
...

异常处理器类似于this postthis post .它使用 NSSetUncaughtExceptionHandler、AppDomain.CurrentDomain.UnhandledException、TaskScheduler.UnobservedTaskException 和 AsyncSynchronizationContext.ExceptionCaught。

我没有像示例中那样在 FinishedLaunching() 中进行初始化,但我认为这不是原因。

是否可以在 Xamarin.iOS 中捕获 EXC_CRASH (SIGABRT) 异常?如果可以的话,怎么办?

最佳答案

您可能想要查看使用运行时框架的 Xamarin.iOS 异常编码(marshal)处理,以及如何使用构建时间标志 (mtouch) 将处理程序安装到应用程序中:

示例:

Runtime.MarshalObjectiveCException += (object sender, MarshalObjectiveCExceptionEventArgs args) =>
{
Console.WriteLine ("Marshaling Objective-C exception");
Console.WriteLine (" Exception: {0}", args.Exception);
Console.WriteLine (" Mode: {0}", args.ExceptionMode);
};

Mtouch选项:

--marshal-objectivec-exceptions=
default
unwindmanagedcode
throwmanagedexception
abort
disable

回复:https://learn.microsoft.com/en-us/xamarin/ios/platform/exception-marshaling

关于ios - 在 Xamarin 中捕获 EXC_CRASH (SIGABRT) 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57657673/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com