Why is DomainUnload not raised for the default AppDomain

  • Thread starter Thread starter JohnH
  • Start date Start date
J

JohnH

Hi,

Does anyone know why the DomainUnload is not raised for the default
AppDomain.

I'm trying to get some shutdown code in a dynamically loaded assembly
called before the application shuts down.

I tried adding a handler for the DomainUnload event to the
AppDomain.CurrentDomain, but this does not get raised because it is the
default Domain.

Can anyone suggest an alternative?

I can't use a Finalizer as I have no control over the order in which
objects are disposed and could result in the shutdown code failing.
Also the hosting application has no reference to the loaded assembly.

Basically, I need a way for the assembly to know when it is about to be
unloaded.

Thanks,
John
 
By the time the DomainUnload event happens for your default app domain, your
code has stopped executing. You can probably do what you need to with the
ProcessExit event on the default AppDomain.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top