There are many topics that cover this issue. But nevertheless, I have a problem.
I load the assembly into a new AppDomain as follows:
public void Run() { //There the problem. //As Panos Rontogiannis mentioned the thread is created in default AppDomain new Thread(RunApp).Start(); } private void RunApp() try { AppDomain.CreateDomain("domain name").ExecuteAssembly("path to assembly"); } catch (Exception _e) { MessageBox.Show("Unhandled Exception.\n" + _e); } }
In the main method of the loaded assembly, I signed my handler for the UnhandledException event:
AppDomain.CurrentDomain.UnhandledException += handleException;
The handler itself:
public static void handleException(object a_s, UnhandledExceptionEventArgs a_args) { var _e = (Exception)a_args.ExceptionObject;
But wherever an exception is thrown in a loaded assembly, the handler is not involved. I have an exception only by default AppDomain (first try{} catch{} ).
source share