Creating a plug-in system using .NET?

How could I implement a plug-in system using the CLR? By plug-in, I mean dynamically load DLLs at run time based on a list in a text file, and then having those DLLs contain an object that can interact with the main "driver" program. So I could have my main program, and it could be instructed to load any number of DLLs at runtime and create instances of a class in those DLLs. I imagine it would involve giving all the object DLLs a specific interface, but does anyone know exactly how all the dynamic loading and stuff could be done?

Any help is much appreciated. Thanks.

Comments

  • I actually just did this not but 2 days ago, but my code is at home, so forgive me if this isnt exact..

    Collection asmAssemblies= new Collection();

    foreach(string dllFileName in dllFileList)
    {
    asmAssemblies.add(System.Reflection.Assembly.LoadFrom(dllFileName));
    }

    this will load all the dlls so you can use them.

    Use System.Reflection.Assembly.CreateInstane("Full Namespace Name of Class") to get a useable object from it.

    to list the classes in an System.Reflection.Assembly, use

    Type[] asmTypes = System.Reflection.Assembly.GetTypes();

    then you can do a foreach() on that to get the full name of the class.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion