object run-time loaded lib RRS feed

  • Question

  • I want to write a program that can use one of several dlls provided that they implement particular interface. Which technology should I use? What comes to my mind:
    1. Ordinary c++ DLL. But there is no run-time loading.
    2. LoadLibrary. But there is no easy to use object interface.
    3. COM. From what I read both object interface and run-time loading should be possible but I found no tutorials demonstrating it. Any hints? Any links?
    Wednesday, July 18, 2007 1:28 PM


All replies

  • Personally I would use .Net (C#) to implement what you require, from your question you describe a plug-in pattern or possibly the 'inversion of control' design pattern IMO.



    These can be implemented very easily in .Net, in fact there are several frameworks that are specifically design for this, Spring.Net is such a framework - this fundamentally allows you to create an instance of an interface at runtime from a value in a configuration file.


    A more light weight MS implementation 'Managed Add-In Model' is available in Orcas CTP and Jesse Kaplan gives an overview in the MS 'Architecture Journal' issue 12 - this is well worth a read if you can get a copy.





    Ollie Riches

    Wednesday, July 18, 2007 2:11 PM
  • Ollie's answer rocks, the injection framework is great.

    Here is a great place to start:


    Wednesday, July 18, 2007 5:41 PM


    My pick, like the other guys would be C# too.


    Dependency Injection is definitely a good way to go, for sure.


    Probably not as clean a solution, but you could also use reflection, depends on how all this is to be used really.





    Wednesday, July 18, 2007 9:49 PM
  • Thanks for the tips but I'm not sure if pure .NET would be acceptable (political decision). Meantime I found that Office applications can be extended with COM add-ins. VS even has a wizard to create them. But how do I create host application to use such add-ins?
    Thursday, July 19, 2007 3:31 PM
  • Not sure about this but I think the phrase 'COM add-ins' implies that it would be an extension of an Office application therefore you require the respective Office application to be running...


    There are plenty of other forums and groups where you can get detailed advice about Offfice and developing COM add-ins.


    Ollie Riches

    Friday, July 20, 2007 3:31 PM
  • Hi Tomasz,

       if you need to do this with C++ (you mentioned that .NET is not an option) I suggest you to ask the experts on that programming language (they have their own forum) about how to apply dependency injection


       The Visual C++ forums are at

    Thursday, August 9, 2007 6:27 PM