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…

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!

Leave a Reply

Comment Policy:

  • You must verify your comment by responding to the automated email that is sent to your email address. Unverified comments will never show.Leave a good comment that adds to the conversation and I'll leave your link in.
  • Leave me pure spam and I'll delete it.
  • Leave a general comment and I'll remove the link but keep the comment.

Notify me of followup comments via e-mail