tags:

views:

111

answers:

1

I'm new to using appdomains, so I'm learning as I go.

I'm making use of appdomains to isolate plugin instances that I'm loading at runtime. If I am referencing a plugin object (in its own appdomain) from the main appdomain and I unload that plugin appdomain, will it fully unload?

My understanding is that by referencing the plugin instance from the main appdomain, I'm actually referencing a transparent proxy, so I'm not actually directly referencing the object. Due to this, I believe there isn't an issue, but I want to make sure my understanding is correct.

+2  A: 

Your understanding is correct: objects in one appdomain cannot really reference objects in another appdomain, so unloading an appdomain will truly release all objects in that appdomain (and your proxy objects become stale).

There are still various problems with unload: if certain code is currently executing in the appdomain (e.g. native code), then Unload will fail with an exception. So you should make sure that all threads have returned out of the AppDomain before trying to unload it.

Martin v. Löwis
Thank you for the additional information!
oakskc