Need help: unloading Assembly (DLL)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to use assemblies (Window Forms as .dll) so that I can replace the form while the main application is running. To accomplish this, I used Assembly.LoadForm to manually load the assembly when I need it from a .DLL file. I then use CreateInstance to create the instance of the class, and then use the instance like I would use is with a normal design-time included assembly.

But the problem is, no matter how I try with closing the form, assigning the instance to Nothing and calling garbage collection I can't get the application to release the DLL so I can overwrite it.

Anyonne have a solution for this? I would really appreciate some help.
 
An assembly can only be unloaded by unloading the appdomain it is loaded in.
You will need to create a new appdomain and load the assembly up into the
context in the appdomain.

LilleSkutt said:
I want to use assemblies (Window Forms as .dll) so that I can replace the
form while the main application is running. To accomplish this, I used
Assembly.LoadForm to manually load the assembly when I need it from a .DLL
file. I then use CreateInstance to create the instance of the class, and
then use the instance like I would use is with a normal design-time included
assembly.
But the problem is, no matter how I try with closing the form, assigning
the instance to Nothing and calling garbage collection I can't get the
application to release the DLL so I can overwrite it.
 
Back
Top