none
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

Answers

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.

     

    http://martinfowler.com/articles/injection.html

    http://www.theagiledeveloper.com/commentaries/4

     

    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.

     

    http://blogs.msdn.com/clraddins/archive/2007/03/05/new-system-addin-features-in-march-s-orcas-ctp.aspx

     

    HTH

     

    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:

    http://www.springframework.net/

     

    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.

     

    Cheers,

     

    Martin.

    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 http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=8&SiteID=1

    Thursday, August 9, 2007 6:27 PM