Assembly a = Assembly.LoadFile(Application.ExecutablePath);
Type[] types = a.GetTypes();
foreach (Type t in types)
{
if (t.BaseType.Name == "Form" || t.BaseType.Name == Formname)
{
Form f = (Form)Activator.CreateInstance(t, true);
if (f != null)
{
if (f.Text == Formname)
{
f.ShowDialog();
}
}
}
}
也可以用Assembly.LoadFile来对dll文件进行读取