Can I isolate my current AppDomain from breaking when another loaded AppDomain is loading an unhandled exception?

Probably a copy: Can I prevent an uncaught exception in another AppDomain application when closing the application?

I tried all day to find out the answer to this question.

I just want to make sure that there really is no answer before I throw away all the code that I did to isolate my drivers inside my separate areas of the application and replace it with old-school processes.

So, a formal question.

Having a default ad-default domain in which I create a new addomain domain, ad-hosted, can I avoid these unhandled exceptions from the "ad placement" that breaks the "default ad"?

I know that I can watch for exceptions by connecting to the UnhandledException event in the "advertizing" domain, but I cannot find a way to stop them from propagating to the "default" domain.

It's true? But why do we even want AppDomain if they do not provide isolation?

EDIT: The answer is unfortunately not, see this answer for an explanation: AppDomain handling exceptions

+7
source share
1 answer

The only way to isolate exceptions in a thread in another appdomain from a default domain break is to use:

<runtime> <legacyUnhandledExceptionPolicy enabled="1"/> <runtime> 

which sets the IsTerminating flag for unhandledexception to false and will not disable the default domain.

In our case, we decided to connect to the UnhandledExceptionHandler in both domains. Then we run semafore in in the "ad placement", which will be picked up by the stream created for this purpose in "ad-default", which then, in turn, places the "ad placement"

This is a hack and probably will not survive in future generations of the framework, but makes it "ad-default" more reliable, since it will not be broken into unhandled exceptions in the "posted ad"

we also attach an event handler in "ad-default", which will send the sender as appdomain and check if an exception occurred in "ad-default", if so, we also destroy the "default declaration", emulating .net 2.0 behavior, even with the runtime setting described above.

Hopefully this will give someone a hint on how to make a more flexible host plugin.

+3
source

All Articles