Board index » Visual Studio » Plugins and Late Binding
|
cowboy88
|
Plugins and Late Binding
Visual Studio70
Hi, I have some code to load some plug-ins, but the code requires me to know the name of the class to load (here: SamplePlugin, derived from IPlugin) : (Here is some C# code, but I use VB.Net to code my program) using System; using System.Reflection; public class Driver { static void Main() { Assembly assembly = Assembly.LoadFrom ("myplugin.dll"); Type t = assembly.GetType ("SamplePlugin"); IPlugin plugin = (IPlugin) Activator.CreateInstance(t); plugin.SayHello(); } } The problem is, I don't want to have to know the name of the class I want to load... I want to load the new module and get an instance of the class that derives IPlugin. Is there a way to do so? In C++ for the same purpose, I had a win32 dll with an extern function that returned an instance of the contained class, so I loaded the dll, called the function and I was ready to proceed. Is there something similar I can do with .NET class libraries? thanks - |
