Dynamically loading assemblies...

G

Guest

I would like my application to be able to load modules dynamically and release them once they aren't needed. For example in c++ I would load a dll containing the required function, run it, then release the dll after it's no longer needed. What are my options in c#? From what I have read so far I can load assemblies containing the required code to execute but I can't release it without releasing the main application domain that loaded it. Is my only option to create another application domain where I can then load the executable and then release it by releasing that domain? It seems that this creates a lot of overhead to simply be able to unload those assemblies once they aren't needed. Any help or suggestions welcomed.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Robert,

Unfortunately, creating a dedicated AppDomain and then shutting it down to
unload the assembly loaded seems to be the only option for now. This also
incurs making the classes in the loaded assembly derived from
MarshalByRefObject to be callable from the main AppDomain.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Robert Vasquez said:
I would like my application to be able to load modules dynamically and
release them once they aren't needed. For example in c++ I would load a dll
containing the required function, run it, then release the dll after it's no
longer needed. What are my options in c#? From what I have read so far I
can load assemblies containing the required code to execute but I can't
release it without releasing the main application domain that loaded it. Is
my only option to create another application domain where I can then load
the executable and then release it by releasing that domain? It seems that
this creates a lot of overhead to simply be able to unload those assemblies
once they aren't needed. Any help or suggestions welcomed.
 

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