You can add assemblies (or any other arbitrary info) under appSettings and use ConfigurationManager class to read it at run-time. Then just call Assembly.Load or Assembly.LoadFromFile to load it and Assembly.GetTypes to retrieve type information. Call Assembly.CreateInstance to create object out of types. A little example:
// Get assembly file name from config file
string asmName = ConfigurationManager.AppSettings["dynamicAssembly"];
// Load assembly
Assembly asm = Assembly.LoadFile(asmName);
// Go through every type in assembly and create instance of them
foreach (Type type in asm.GetTypes())
{
object typeObj = asm.CreateInstance(type.FullName);
// Go through every method in type instance and invoke them
foreach (MethodInfo mi in typeObj.GetMethods())
{
mi.Invoke();
}
}
This works with only a single assembly. That instance creation and method invoking stuff is pretty stupid but it's there just for example.
But as Planoie said, could you explain little further what you are planning to do. Reflection is a slow way to make things and depending on the case there are better alternatives.
|