中捕获所有崩溃异常

中捕获所有崩溃异常

本文介绍了如何在 monotouch/ios 中捕获所有崩溃异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 main.cs 中封装了日志代码来捕获异常,但是使用 monotouch 构建的应用程序通常会在 iPad 中崩溃,而且我找不到任何日志.(部分代码包含多线程操作和wcf服务)

I have wrapped log code in main.cs to catch the exception, but the app build by monotouch usually crash in iPad, and I cannot found any log. (some code contain multithread operation and wcf service)

如何捕获所有崩溃异常?

How can I catch all crash exception?

public class Application
{
    // This is the main entry point of the application.
    static void Main (string[] args)
    {
        // if you want to use a different Application Delegate class from "AppDelegate"
        // you can specify it here.
        try
        {
            UIApplication.Main (args, null, "AppDelegate");
        }
        catch (Exception ex)
        {
            Util.LogException("Main",ex);
        }
    }
}

推荐答案

Native crashes 不能转为托管异常(进程状态无效,所以没有办法安全继续).

Native crashes can't be turned into managed exceptions (the state of the process is invalid, so there is no way to continue safely).

有两种类型的信息可以帮助您(或帮助他人帮助您)了解正在发生的事情:

There are two types of information that will help you (or help others help you) figure out what's going on:

  • 崩溃报告.
  • 设备日志.

崩溃报告可以在 Xcode 的 Organizer 中找到,设备日志可以在 MonoDevelop 的 iOS Device Log pad 中找到.这里有更详细的说明如何找到每个.

You can find the crash report in Xcode's Organizer, and the device log in MonoDevelop's iOS Device Log pad. Here is a more detailed description how to find each.

这篇关于如何在 monotouch/ios 中捕获所有崩溃异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:01