Reflection - Loading The Assembly

Tagged with:

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…

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Tagged with:
kick it on DotNetKicks.com

4 Responses to “Reflection - Loading The Assembly”

  1. ramil Says:

    Thanks, this is a good start for me.

  2. Mihail Says:

    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).

  3. Dave Says:

    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.

  4. Mihail Says:

    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!

Leave a Reply