How to create a global error/exception handler?

In all systems I previously wrote code for I could create a global exception handler. AppDomain.CurrentDomain.UnhandledException is one example. TaskScheduler.UnobservedTaskException is another. Then, there are more specific handlers on Android or Windows Desktop. Nothing I tried worked for Tizen.NET. I, also, tried to put the whole Main in try block to no avail

  private static void Main(string[] args) {
     AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

     try {
        var app = new Program();
        Forms.Init(app);
        FormsCircularUI.Init();
        app.Run(args);
     }
     catch(Exception objException) {
        Log.Fatal(objException.ToString());
     }
  }

Can anybody give me the list of all unhandled exception handlers to cover all exception situations ideally including exceptions coming from the very core/native?
In Debug I want to log them. Later in Release I’d like to send them to Analytics.

Hi,
You can find detail information and implementation of AppDomain.CurrentDomain.UnhandledException in dot NET core platform here.

You can find more exception here with implementation example.

There is also a implementation issue that has been discussed in the stack overflow. You can follow that. May be it can help you to implement exception handler in your project.

It looks like you misunderstood the question. I’m perfectly aware of how to implement handling of AppDomain.CurrentDomain.UnhandledException and all other handlers I know of.

My point was that all handlers that I added to the app didn’t make a difference, including direct try/catch. Anyway, there are exceptions which are not caught. They just crash the app or make the debugger stop at app.Run(args); line if it is attached but no global exception handlers are invoked as well as the catch block.

I hoped that there is another unhandled exceptions handler somewhere in the Tizen.NET SDK that would allow me to catch unhandled exceptions. Is there?

Hi,
Sorry for the misunderstanding at first. It is really hard to understand the issue without knowing the error that you are getting from the application.

Providing error log may help to understand better.

Moreover you may know that Tizen.NET programming environment consists of the following environments.

  1. .NET Standard API
  2. Xamarin.Forms
  3. Tizen.Wearable.CircularUI
  4. TizenFX API

Check this documentation to know details about these four and their API references.

You can check API references for .NET and Xamarin.Forms in their respective site. You can also check the API reference for Tizen.Wearable.CircularUI and TizenFX API.

I’m not talking about one particular error or exception. I want to find a way to process ALL exceptions in the WHOLE app which were not handled, were not in a try/catch. I want to know if there is something similar to AppDomain.CurrentDomain.UnhandledException in Tizen.NET which would allow me to do that. As I already mentioned AppDomain.CurrentDomain.UnhandledException didn’t work. I hope there is something in the Tizen.NET API which would work.