> Hi Jay,
> I Tried What You Suggested And On:
> obj = Activator.CreateInstance(type, New Object() {Setting.Key})
> I'm Getting This Error:
> An Unhandled exception of type 'System.MissingMethodExpression' occurred
in
> mscorlib.dll
> Additional information: Constructor on type PTCore.InitialModule not
found.
> Config File Reads:
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
> <configSections>
> <section name="PlugIns" type="PT.PlugInSectionHandler, PT" />
> </configSections>
> <PlugIns>
> <add plugin="Initial Module" type="PTCore.InitialModule, PTCore"
/>
> </PlugIns>
> </configuration>
> Any Ideas Why? I Have The DLL Compiled And In The Same Directory As The
EXE
> Thanks For The Help
> Mike
message
> > Michael,
> > Look at System.Activator.CreateInstance.
> > What I would suggest is combine it with a custom section in your
> app.config
> > file. The section would contain a list of Plug-Ins available. Your app
> would
> > read the list. One attribute of this list would be the 'type' of object
to
> > create. It would take the form "mynamespace.myclass, myassembly"
> > Where myassembly is the name of your DLL (no .DLL on the end).
mynamespace
> > is the namespace within that DLL, and myclass would be the name of the
> > class...
> > in app.config:
> > <configuration>
> > <configSections>
> > <section name="PlugIns" type="MyApp.PlugInsSectionHandler,
MyApp">
> > </configSection>
> > <PlugIns>
> > <add plugin="My First Plug-In"
> > type="MyPlugIn.PlugInClass, MyPlugIn" />
> > </PlugIns>
> > </configuration>
> > A class in your main app:
> > Public Class PlugInsSectionHandler
> > Inherits System.Configuration.DctioanrySectionHandler
> > Protected Overrides ReadOnly Property KeyAttributeName() As
String
> > Get
> > Return "plugin"
> > End Get
> > End Property
> > Protected Overrides ReadOnly Property ValueAttributeName() As
> String
> > Get
> > Return "type"
> > End Get
> > End Property
> > End Class
> > ' In your main app initialization:
> > Dim settings As IDictionary
> > settings = Configuration.ConfigurationSettings.GetConfig("PlugIns")
> > Dim setting As System.Collections.DictionaryEntry
> > For Each setting In settings
> > Debug.WriteLine(setting.Value, setting.Key)
> > Dim type As Type
> > type = type.GetType(setting.Value.ToString())
> > If Not type Is Nothing Then
> > Dim obj As Object
> > obj = Activator.CreateInstance(type, New Object()
> {setting.Key})
> > End If
> > Next setting
> > NOTE: In the above sample my 'PlugIn' accepts the name of the plugin as
a
> > parameter (the New Object() stuff)...
> > Hope this helps
> > Jay
> > > OK I'm New to VB.NET And I'm Trying To Do Something I Do In VB6 But
> Can't
> > Seem
> > > To Do In .NET for the life of me.
> > > What I Used To:
> > > If VB6 I Would Right Various DLL's to Use As Plug-Ins In My
> Applications,
> > I
> > > Didn't Create A Reference For Them In The Project. I The CreateObject
> > Function
> > > Soemthing Like This:
> > > Dim obj as object
> > > set obj = CreateObject("ApplicationPlugIn.PlugInName")
> > > Since The .NET DLL's Aren't Registered I'm Getting Errors Trying To Do
> The
> > Same
> > > Thing. I'm Hoping Someone Can Shed Some Light On What I Need To Do.
> > > The biggest problem is I do NOT want a reference for the DLL in the
> > Application
> > > since The DLL May or May Not Be On The System.
> > > Any Help Would Be Appreciated, Any code Appreciated even more!
> > > Thanks To All,
> > > Mike