In MonoTouch, how do I register an uncaught exception handler (or similar function)
In Obj-C:
void uncaughtExceptionHandler(NSException *exception) {
public delegate void NSUncaughtExceptionHandler(IntPtr exception);
[DllImport("/System/Library/Frameworks/Foundation.framework/Foundation")]
private static extern void NSSetUncaughtExceptionHandler(IntPtr handler);
// This is the main entry point of the application.
private static void Main(string[] args)
{
NSSetUncaughtExceptionHandler(
Marshal.GetFunctionPointerForDelegate(new NSUncaughtExceptionHandler(MyUncaughtExceptionHandler)));
...
}
[MonoPInvokeCallback(typeof(NSUncaughtExceptionHandler))]
private static void MyUncaughtExceptionHandler(IntPtr exception)
{
var e = new NSException(exception);
...
}