作者在 2009-01-02 16:58:11 发布以下内容
string[] arFile =
System.IO.Directory.GetFiles(Application.StartupPath, "DLLForm.dll");
for (int i = 0; i < arFile.Length; i++)
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(arFile[i]);
foreach (Type type in assembly.GetTypes())
{
object myForm = Activator.CreateInstance(type) as Form;
if (myForm != null)
{
((Form)myForm).ShowDialog();
return;
}
}
}
结果如下:(记得运行前将DLLForm这个DLL与MyApplication放在同一个目录下,否则你要使用绝对路径)