OK - I have a plug in framework where my application can have 3rd party plug-ins added via the .config file (provided they confrom to the IPlugIn interface...)
What I have so far reads the Type Name and checks if it supports the interface OK - but how do I instantiate an object of that type if it does?
I have.....
App.config
Then in the application....Code:<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <!-- Extra custom configuration sections --> <section name="printerEventListeners" type="PrinterMonitorService.CustomConfigurationSectionReaders.PrinterEventListenersSectionReader" /> </configSections> <printerEventListeners> <!-- Key = the unique name by which the listener is known, ClassType = the full type name of the class implementing IPrinterEventListenerBase , CommandLine = startup parameters for that class --> <printerEventListener key="printerEventListener1" classType="PrinterMonitorService.PrinterMonitorLogfileListener" commandLine="c:\printerEventListener1.log" /> </printerEventListeners>
VB Code:
For Each PrintJobListener In PrintJobListeners If PrintJobListener.ImplementingClassType.IsSubclassOf(GetType(PrintJobMonitorListenerBase)) Then '\\ Add an instance of the PrintJobMonitorListenerBase derived class... If ApplicationTracing.TraceVerbose Then Trace.WriteLine("PrintJobMonitorListenerBase derived class: " & PrintJobListener.ImplementingClassType.ToString, Me.GetType.ToString) '<-- What to put here ???? End If End If Next
Thanks in advance,
Duncan




Reply With Quote