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

  • Reflection -The ConstructorReflection -The Constructor Remember, last week we started a series on using Reflection in our .NET applications.  We've loaded the assembly already, so the next step is creating the object.  Today's tutorial will show how to...
  • Reflection and InterfacesReflection and Interfaces Today is the last official installment in the series on reflection.  If you've been following along, you've probably notice that calling code in other classes using reflection is a huge pain i...
  • Reflection – Accessing MethodsReflection – Accessing Methods Today is the next to last installment on reflection.  We will look at how to call methods and pass parameters.  This is going to look a lot like what we've already done in previous sessio...
  • Reflection From a DLL and SerializationReflection From a DLL and Serialization Last week, we finished up our main series on reflection.  For most people, what we covered is all they will ever need.  However, there are a few other things I've needed to know due mainl...
  • Reflection – Calling PropertiesReflection – Calling Properties Today we'll continue our series on reflection by looking at Properties.  If you haven't already seen the videos on how to load the assembly or how to call the constructor, you'll probably want...
  • 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!