Add reference to a dll manually RRS feed

  • Question

  • Hello,

    I wasn't able to figure it out how to do this. I checked docs and forums.
    I have to load dll manually.
    Adding a reference a in vs is not good because:
    - I have to check the existence of the dll before running the app.
    - I should change the referenced dll name at runtime based on the app settings.

    I wonder if I was so blind or it's really not trivial.
    I appreciate any help. Thanks.
    Wednesday, July 4, 2007 6:41 PM


  • Hi,


    You can use the classes in the System.Reflection namespace to load a .NET assembly dll at runtime, what your trying to do is usually referred to as late binding. A couple of classes you want to look at are the AppDomain, Assembly, and Type classes as these are commonly used to load and create instances of classes through late binding.


    There is a bit to reflection and the best place I can think to get good information was a couple of sample chapter that were posted a while back on MSDN, unfortunately I cannot find the page, but you can download them here. There are two books, one VB.NET and one C#, I see your background is C# but do read the VB.NET sample chapter as both really cover a technology expressed in a language rather than any language specific stuff. Worth your while as both books have slightly different coverage...


    Reflection C#

    Reflection VB.NET

    Wednesday, July 4, 2007 7:12 PM