473,606 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding New References at Runtime...

Hello,

My application needs load some dll's at runtime, Is there any way to do it?,
can you show me a working example code?

Many thanks
Nov 21 '05 #1
11 1803
"Juande" <a@b.com> schrieb:
My application needs load some dll's at runtime, Is there any way to do
it?


Take a look at the documentation for 'System.Reflect ion.Assembly.Lo ad*'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Ok thanks,

Now other question please, I have the next code;

Dim Form1 As Form
Form1 =
System.Reflecti on.Assembly.Loa dFrom("MyDLL.dl l").CreateInsta nce("MyDLL.Form 2")
Form1.Show()

How can I check if any dll is still loaded?

Many thanks

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> escribió en el mensaje
news:Od******** ******@TK2MSFTN GP14.phx.gbl...
"Juande" <a@b.com> schrieb:
My application needs load some dll's at runtime, Is there any way to do
it?


Take a look at the documentation for 'System.Reflect ion.Assembly.Lo ad*'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
"Juande" <a@b.com> schrieb:
Dim Form1 As Form
Form1 =
System.Reflecti on.Assembly.Loa dFrom("MyDLL.dl l").CreateInsta nce("MyDLL.Form 2")
Form1.Show()

How can I check if any dll is still loaded?


The DLL will remain loaded until the appdomain that loaded the DLL and/or
obtained type information from the DLL will be released. If you want to
unload a DLL, you'll have to work with a secondary appdomain and remote
interfaces:

<URL:http://www.west-wind.com/presentations/DynamicCode/DynamicCode.htm >
-> "Understand ing how .Net loads code"

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
Juande,

I am curious, how were you able to produce this question in such a short
time, did you really investigate this as Herfried sugested?

Cor
Nov 21 '05 #5
Ok,

I have a large C/S Application (sometimes crashes/quits unexpectedly without
any error), I want to divide in modules (dll) and then load the needed ones,
so I've realized a simply application test to load an example dll to check
System.Reflecti on.Assembly to see how it works, the next step will be check
if the dll is still loaded to doesn't load again.

Herfried; Many thanks for your very quick and useful help.

"Cor Ligthert" <no************ @planet.nl> escribió en el mensaje
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Juande,

I am curious, how were you able to produce this question in such a short
time, did you really investigate this as Herfried sugested?

Cor

Nov 21 '05 #6
Sorry, but I've got another problem, as you know, I load at runtime my dll,
this dll contains a class called MyForm, example code on a click button
event;

Dim MyDLL As [Assembly]
MyDLL = System.Reflecti on.Assembly.Loa dFrom("MyDLL.dl l")
Dim MyForm As Form
MyForm = MyDLL.CreateIns tance("MyDLL.My Form")
MyForm.Show()

This code works fine, but, I want to prevent that if the form is loaded,
doesn't load other instance, How can I do it?

Many thanks in advance

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> escribió en el mensaje
news:Od******** ******@TK2MSFTN GP14.phx.gbl...
"Juande" <a@b.com> schrieb:
My application needs load some dll's at runtime, Is there any way to do
it?


Take a look at the documentation for 'System.Reflect ion.Assembly.Lo ad*'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7
"Juande" <a@b.com> schrieb:
Sorry, but I've got another problem, as you know, I load at runtime my
dll, this dll contains a class called MyForm, example code on a click
button event;

Dim MyDLL As [Assembly]
MyDLL = System.Reflecti on.Assembly.Loa dFrom("MyDLL.dl l")
Dim MyForm As Form
MyForm = MyDLL.CreateIns tance("MyDLL.My Form")
MyForm.Show()

This code works fine, but, I want to prevent that if the form is loaded,
doesn't load other instance, How can I do it?


\\\
Private m_MyForm As Form
..
..
..
If MyForm Is Nothing Then
MyForm = MyDll.CreateIns tance(...)
Else
MsgBox("Form already instantiated!")
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #8
Herfried thanks for your great patience,

When close MyForm and then I want to load it again, it's already
instantiated and doesn't show, in some place of my code when from is closing
I must to set MyForm = nothing, but where?

Thanks

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> escribió en el mensaje
news:e8******** ********@TK2MSF TNGP09.phx.gbl. ..
"Juande" <a@b.com> schrieb:
Sorry, but I've got another problem, as you know, I load at runtime my
dll, this dll contains a class called MyForm, example code on a click
button event;

Dim MyDLL As [Assembly]
MyDLL = System.Reflecti on.Assembly.Loa dFrom("MyDLL.dl l")
Dim MyForm As Form
MyForm = MyDLL.CreateIns tance("MyDLL.My Form")
MyForm.Show()

This code works fine, but, I want to prevent that if the form is loaded,
doesn't load other instance, How can I do it?


\\\
Private m_MyForm As Form
.
.
.
If MyForm Is Nothing Then
MyForm = MyDll.CreateIns tance(...)
Else
MsgBox("Form already instantiated!")
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #9
"Juande" <a@b.com> schrieb:
When close MyForm and then I want to load it again, it's already
instantiated and doesn't show, in some place of my code when from is
closing I must to set MyForm = nothing, but where?


You may want to add a handler to the form's 'Closed' event using
'AddHandler' and set the variable to 'Nothing' there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #10

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

Similar topics

8
6577
by: filip stas | last post by:
How do i add references during runtime?
2
1490
by: MLH | last post by:
A97 topic. Opening a new thread related to some other discussions - > > > just to make sure < < < that installing an OCX or adding an mdb using references other than the BASIC-3 that I use in all my other A97 MDB's will not change the references in any of those other existing MDB's.
2
13086
by: Lisa Jones | last post by:
Hi I am trying to add web reference to my code to use web services . (I am using VS 2003) so I go to add references/ select web reference. After selecting the right web service from my local machine and rename it to something other than local host (aWebService) and then Adding the cod sing aWebService namespace WebClien /// <summary /// Summary description for Form1 /// </summary
5
8701
by: Craig Lister | last post by:
Newish to c# - Coming from Delphi. I'd like to add 255 checkboxes to a screen at runtime, and name then cb1, cb2... cb255 The code below does not work, but, how can I get this to work? public void prepScreen() { CheckBox chkBox = new CheckBox;
18
3772
by: Praveen Ramesh | last post by:
Hi, Is there any way to add the @Assembly reference to the aspx files programmatically from inside a custom control (when it gets dropped on to the page from the toolbox)? I have a custom control - MyControl that implements an interface in another custom assembly - InterfaceAssembly. When MyControl gets dropped on to the page and run, it results in a "InterfaceAssembly not found" exception. I am aware that this can be fixed by...
3
5756
by: MIGUEL | last post by:
Hi all, I'm quite lost with how adding web references to a project creates proxy classes. I've developed a web service with two classes inside and that contains three references to three DLLs. After building it up, I've deployed it on the web server. From my Windows application, I then add a web reference to that web service.
3
1989
by: _DS | last post by:
The two obvious methods for ref'ing assemblies are: Add a reference and 'Browse' for the actual DLL OR Add existing project to the solution, then add a ref to 'Project'. 1: I'd like to find out what the latter method is doing. I'm assuming that it makes sure that debug exe gets matched to
5
49800
by: Michael Russell | last post by:
Hi all, Using C#, I've created a simple wrapper class for using Excel. I have Office Pro 2003 installed on my devel machine. The wrapper class works great, reading and writing to/from Excel. To do this, I created a reference to "Microsoft Excel 11.0 Object Library", and have a "using Excel;" directive. I decided to add a method for creating a TextBox using the Shapes.AddTextBox method, which requires a
7
4318
by: doina | last post by:
Hello, Can I have runtime polymorphism using references. I knew that runtime polymorphism could be obtained only by pointers, but now I have tried this in Visual C++ 8.0: #include <iostream> using namespace std;
0
8024
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7959
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,...
1
8105
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8310
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6781
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
5968
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
5466
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();...
1
2451
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1305
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.