472,141 Members | 1,198 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,141 software developers and data experts.

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 3084
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.