May 11, 2006

Loading an Assemby and Creating an Object by Reflection

// Load the containing assembly
Assembly assembly = Assembly.LoadFrom(assemblyPath);
// Get the full name for the object including namespace
string objName = ProjConfig.Instance.NamespaceName
+ "." + className; // Create the object obj = assembly.CreateInstance(objName); // Convert to required class or interface Thingy myThingy = obj as Thingy;

No comments: