473,722 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3182
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.AppDomai n.CreateDomain) , using
reflection to load the dll that you are interested in (see the
System.Reflecti on namespace), then unloading the AppDomain when you are
done with the dll (using System.AppDomai n.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 assemblyInstanc e = Assembly.LoadFr om(assembly);
assemblyInstanc e.GetType(type) .InvokeMember(m ethod, BindingFlags.Pu blic |
BindingFlags.In vokeMethod |
BindingFlags.In stance,null,ass emblyInstance.C reateInstance(t ype), null);
"Daniel" wrote:
How do i dynamicaly load and unload a C# dll at runtime

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2857
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to be loaded, which function to be called, and what are the parameters to call the function. Thank you very much!
1
323
by: Daniel | last post by:
How do i dynamicaly load and unload a C# dll at runtime
1
3605
by: DB2 Novice | last post by:
Hi, What are the utils provided by IBM to fast load and unload DB2 in Unix and Windows env. I read about High Performance Unload and this is just Unload, waht about Load? What is the best way to dump a 2TB data? DB2Novice
2
8494
by: Patrick Blackman | last post by:
I have a program that search the application path for all the Dll that implement a certain interface IText ,when a Dll with the interface is found ,I run a method called IText.Format() which works very beautifully but then I would like to unload the Dll after running the ITextFormat procedure. Any ideas about doing this? I was told that it had something to do with creating a new AppDomain ... Any help would be appreciated.
2
10848
by: Lauren Hines | last post by:
Hello, I have read numerous post stating that the only way to unload an assembly (DLL in my case) is to create a separate AppDomain, load the assembly, then unload it by calling AppDomain.Unload. When trying to delete the DLL file I get an exception that access is denied. When trying to copy over the DLL file, I get an exception that it is being used by another process.
2
6873
by: brianbender | last post by:
I am trying to load and unload assemblies dynamically and call methods and properties when loaded into an Appdomain I can load assemblies all day in the current AppDomain without references and without interfaces if need be. But try as I may they will ot unload. I have been working on this problem for weeks. I have seen other apps using Remoting but I know there has got to be a way to create a child AppDomain and reference obkect via...
2
1585
by: Chris Dunaway | last post by:
I am using reflection to load an assembly dynamically at runtime. If there are classes in the assembly that implement a particular interface, I put an entry in a list for later use. My questions concerns the loading of the assembly. Since there is no way to unload the assembly, what happens if a assembly I have loaded does not contain any classes that implement my interface? Does the assembly just hang around until the app ends? Does...
2
2210
by: Artem | last post by:
When I use the method Thread.Abort, it only sends a request of aborting to OS to stop a thread. The thread itself isn't killed and allocated resources aren't released. I tried to run that thread inside of a domain, specially created for it, but the domain can't be unloaded, 'till there are some not- stopped threads. Please, tell me are there any ways to immediately stop a thread or unload a domain? Thanks beforehand!
6
4724
by: Ronald S. Cook | last post by:
We have a Windows app that has one main form (a shell, sort of). We then load user controls into a panel on the form depending on what the user has selected. Our current code to unload the existing user control and load the newly selected one is pretty bulky. Every time we add a new user control to the project, we have to add some code in the section where we are loading/unloading. Is there a more dynamic, more efficient way to...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9238
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.