vnarod Posted May 6, 2003 Posted May 6, 2003 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) Quote
Night Posted May 7, 2003 Posted May 7, 2003 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...) Quote
*Gurus* divil Posted May 7, 2003 *Gurus* Posted May 7, 2003 Use oAssembly.GetTypes() to get an array of the classes inside. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
vnarod Posted May 7, 2003 Author Posted May 7, 2003 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? Quote
*Gurus* divil Posted May 7, 2003 *Gurus* Posted May 7, 2003 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. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
vnarod Posted May 7, 2003 Author Posted May 7, 2003 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? Quote
*Gurus* divil Posted May 7, 2003 *Gurus* Posted May 7, 2003 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. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.