Got a question after my reflection talk I gave to the User Group last week. The attendee wanted to load a dll from the disk and reflect on it. The assembly class has a LoadFile method that makes this easy as pie. Here is a code sample.
//Read the dll from the disk
Assembly assembly = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + "Microsoft.Practices.ObjectBuilder.dll");
//Print out some information about it
foreach (Module module in assembly.GetModules())
{
Console.WriteLine("{0}", module.Name);
foreach (Type type in module.GetTypes())
{
Console.WriteLine(" {0}", type.FullName);
foreach (MethodInfo method in type.GetMethods())
{
Console.WriteLine(" {0}", method.Name);
}
}
}
Console.ReadKey();