Dynamically load a type from an external assembly

Posted by Water Cooler v2 on Stack Overflow See other posts from Stack Overflow or by Water Cooler v2
Published on 2010-03-28T18:52:34Z Indexed on 2010/03/28 19:13 UTC
Read the original article Hit count: 206

Filed under:

From managed code, how do I load a managed type from another assembly at runtime, assuming the calling code does not have a static reference to the assembly?

To clarify, let's say I have class Lib in Lib.cs compiled into Lib.dll. I want to write a class Foo in a separate assembly called Foo.dll, that does not have a reference to Lib.dll statically, but instead loads Lib.dll and then reflects on for the presence of the class Lib and then calls a method on it.

Sorry for such an obvious question on Reflection. I figure it'll take much lesser time to get the answer on a forum that to read a few articles.

© Stack Overflow or respective owner

Related posts about reflection