MonoDroid: Global Error Handler

后端 未结 3 739
你的背包
你的背包 2020-12-21 04:53

Is there a way to create a global error handler for MonoDroid? My debugger is broken so I need a way to see the exception info while the application crashes.

3条回答
  •  星月不相逢
    2020-12-21 05:30

    It seems that AndroidEnvironment.UnhandledExceptionRaiser is what you're looking for:

    //that's a dirty-code example, do not use as-is! :)
    AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) =>
                    {
                        File.AppendAllText("tmp.txt", args.Exception.ToString());
                    };
    

提交回复
热议问题