Load Code Dynamically

I recently needed to programmatically load some code from a separate assembly.  I knew this could be done, but wasn't sure exactly how.  After spending 20 minutes searching the net for some examples, I decided to give up and try some things on my own.  Here is my solution.  Hopefully I will save someone the trouble that I experienced.

AppDomain CurrentDomain = null;
ICustom CustomObject = null;

// reference the current Application Domain
CurrentDomain = AppDomain.CurrentDomain;

// create the object
CustomObject = (ICustom)CurrentDomain.CreateInstanceAndUnwrap(“Assembly name goes here“,“Type name goes here“);

Comments