Reflection – Loading The Assembly

Recently, I received a question from a web visitor asking me to cover reflection.  So, I’m going to start a series on reflection.  Remember, if you have any questions you can ask me using the “Ask A Question” form.  Just look for the “Click Here to Ask A Question” button at the top of the page.


Today, we are going to cover loading the DLL…


Other Related Items:

Hue Women's Micro Net LinerHue Women's Micro Net LinerKeep your feet feeling fabulous with this Micro Net Liner With Cotton Sole by Hue!
Lock LacesLock LacesTying your shoes is a thing of the past with the unique loop system and high-impact lightweight plastic cordlock. No more tying, retying, double knots... Read More >
Murder, She Wrote - The Complete Second SeasonMurder, She Wrote - The Complete Second SeasonJessica Fletcher is a famous mystery writer who has a knack for solving mysteries on and off the pate. Along with the quirky residents of Cabot Cove, Maine, Jessica is joined in her mayhem by some of the most celebrated guest stars of screen and stage. Investigate all 22 episodes of season 2!

Related Post

4 Responses to “Reflection – Loading The Assembly”

  • ramil:

    Thanks, this is a good start for me.

  • Mihail:

    The part with adding the library reference to your form project – you can create the object via new instead of loading the assembly… I understand the purpose but it makes is a bit confusing (LoadFrom(path) would of avoid adding the reference and made it a bit clear IMHO for this particular exercise).

  • Dave:

    Of course you could instantiate it directly, but I clearly state that the reason we added the reference is to get the dll in the same directory as the EXE which is required for the standard way of loading an assembly, which is what 99% of the people who would watch this video would want to do.

    If I wanted to illustrate how to load from a directory outside of the default directories, I would have used LoadFrom, or some other method that did that.

    The problem with LoadFrom is that it is as equally confusing because then everyone would think that LoadFrom is the way to load an assembly. Most of the time it is not.

  • Mihail:

    I agree about LoadFrom() – just wanted to clarify in a way that the references to the libraries are not needed in a real reflection case – I am the 1% that got a bit confused about adding the references.
    Anyway – thanks for doing it, great way to learn something!

DotNetNuke Sponsor

 

Most Valuable Blogger
Sponsor