Load DLL only when needed

  • Thread starter Thread starter Jarod_24
  • Start date Start date
J

Jarod_24

For my Application i have created 3-4 different forms that can be used as the user interface for the program.
The user specifies which one he/she wants to use in a ini-file and then my code will create an instance of that form.

Currently all the forms are placed in a "Forms" project inside the programs solution and the whole shebang is loaded up at program
startup.

I was thinking of separating each the forms into it's own .DLL (Skin1.dll, Skin2.dll and so on), and then based on the entry in the
ini-file only load one of them.

All the forms are inherited from a "FormsTempelate" class so they all look the same, regarding methods, and functions.

I was looking at using System.Reflection to do this, but im a little stumped.

http://msdn.microsoft.com/library/d...stemreflectionassemblyclassloadfromtopic1.asp

As far as i see this examplecode will allow me to list all the methods, and their arguments in the assembly, but how do i create an
instance of the Form inside, and how do i execute the code?

please post links to code/articles that explains all this
 
Once you have loaded the assembly and you have located the exported (public)
type (Assembly.GetExportedTypes) which derives from FormsTemplate, you
create an instance of the type using System.Activator.CreateInstance(type)
(see overloaded methods too). This returns an object that you must cast to
FormsTemplate.

About your plugin architecture, see:

Creating a Plug-In Framework
http://msdn.microsoft.com/asp.net/c...library/en-us/dnaspp/html/pluginframework.asp

Search Dynamically for Plug-Ins
http://msdn.microsoft.com/asp.net/c...ibrary/en-us/dnaspp/html/searchforplugins.asp

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top