Unloading a GUI Assembly

G

Guest

Hi

I have GUI assembly which is loaded into a seprate Appdomain using AppDomain::Load method, after using it's function i unloaded the assembly by calling the AppDomain.UnLoad() method. But i can still use the UI components displayed earlier when i loaded the Assembly. How is this possible, it should not show up or throw some exception when i use the controls right?

Please advice me how this behavior is possible even after i unloaded the assemblie's App Domain

Any body Please help me
 
W

Willy Denoyette [MVP]

You did not unload the assembly, you did unload the appdomain.
Willy.
 
G

Guest

Hi Willy

As per the MSDN documentation, there is no way we can unload an assembly, only way is to unload the AppDomain where the assembly is loaded. What do u say about this.
 
W

Willy Denoyette [MVP]

I know that, but are you sure the assembly was loaded in a secondary domain,
or are you sure the assembly (code) was not used by or referenced in another
domain ? In all these cases the CLR will unload the domain but keeps the
assembly loaded.
Can you post a small but complete repro.

Willy.
 
M

Mike Krueger

Hi

If you use a Windows.Forms component in this assembly it is not possible
to unload it ...
When you load the assembly in a remote domain and use a control (for
example) in this assembly the assembly is loaded into the calling domain
too. Therefore when unloading the other domain you can use the stuff
from the assembly you wanted to unload with the remote domain.

If it is possible try to load the assembly with Load(byte[]) ... and
re-load them when you re-new the assembly. With this method you'll have
a memory leak but you're able to 'update' the GUI assembly.

btw. the IDEs do the same thing when you use custom controls in the
forms designer and recompile the project.

Regards
Mike
 
G

Guest

I was not knowing the fact that, if i create a new AppDomain and call the Load method for the Windows Form based Assemblies it will also be loaded to the Default Domain.

In my case My GUI Assembly was loaded into the Default Domain also, that causes it not to unload, when i unload the new AppDomain created.

That clears my doubt.

Thanks for your help Mike and Willy.
 

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

Top