How to get objects from DLL?

vnarod

Regular
Joined
Mar 22, 2002
Messages
84
I have created a DLL that contains several forms. At run time I need to get all form names and forms from this DLL.
How can I do it? I can get the assembly, but I am confused how to get individual objects from it.

sFile = "LocalManagement.DLL"
oAssembly = System.Reflection.Assembly.LoadFrom(sFile)
 
I have implement it like this:
- Make a DLL
- Expose method like: Open form A / Open Form B
- If you need form interaction --> Open other forms from form A/B (in DLL code) and so on...(I mean form A/B is some start points...)
 
1. Thank you. Do I unsderstand correctly that I need this to load all forms?

dim ar as ArrayList
dim oTypes as System.Type
oTypes = oAssembly.GetTypes
for i=0 to ubound(oTypes)
ar.Add oAssembly.CreateInstance(oTypes(0).FullName)
Next

2. What is the good way to store a form display name? Type.Name gives me "frmData" and I need to display "Transaction Data". Of course, I can make it public property of a form but then I will have to load form in order to read it. Is there some property that I could use to store it so I can get display name without loading form?

3. How does it work memory-wise? Will DLL stay in memory after first accessed? How can I make sure that it does not? Can keeping 150 form in memory introduce memory problems?
 
1. Use Type.IsSubClassOf(GetType(Form)) to make sure first.
2. I would use an attribute to attach a text "friendly" description to each form, which you can retrieve with reflection without having to create an instance.
3. Let the GC worry about that.
 
2. I will try to find in help how to do that. If you have a short sample, I would greatly appreciate it.

3. What is GC?
 
2. I don't have an example just lying around, but if you don't manage it I will write one for you.

3. The Garbage Collector.
 
Back
Top