469,902 Members | 1,805 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

How do i dynamicaly load and unload a C# dll at runtime

How do i dynamicaly load and unload a C# dll at runtime

Nov 16 '05 #1
3 2976
Hello Daniel,

You can't do that.
How do i dynamicaly load and unload a C# dll at runtime

Nov 16 '05 #2
Actually you can do this. You will need to look into crating new
application domains (via System.AppDomain.CreateDomain), using
reflection to load the dll that you are interested in (see the
System.Reflection namespace), then unloading the AppDomain when you are
done with the dll (using System.AppDomain.Unload).

If you are interested in seeing an "in production" working example of an
application that can do this, take a look at NUnit. NUnit allows you to
replace the test DLLs at runtime and the application will unload the
ones it was using then load up the new ones.

Hope this gets you going in the right direction.

Have A Better One!

John M Deal, MCP
Necessity Software

Hayato Iriumi wrote:
Hello Daniel,

You can't do that.
How do i dynamicaly load and unload a C# dll at runtime


Nov 16 '05 #3
I'm not sure if this is what you need.
You have a dll and you want to late bind...

take a look at the following code, it loads a form from a dll. Everything
can be configured at runtime...
string assembly = "ClassLibrary1.dll";
string method = "Show";
string type = "Form1";
Assembly assemblyInstance = Assembly.LoadFrom(assembly);
assemblyInstance.GetType(type).InvokeMember(method , BindingFlags.Public |
BindingFlags.InvokeMethod |
BindingFlags.Instance,null,assemblyInstance.Create Instance(type), null);
"Daniel" wrote:
How do i dynamicaly load and unload a C# dll at runtime

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by DB2 Novice | last post: by
2 posts views Thread by Patrick Blackman | last post: by
2 posts views Thread by Lauren Hines | last post: by
2 posts views Thread by brianbender | last post: by
2 posts views Thread by Chris Dunaway | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.