How can I catch all crash exception in monotouch/i

2019-02-27 11:14发布

问题:

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);
        }
    }
}

回答1:

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:

  • The crash report.
  • The device log.

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.