System.Reflection.Assembly a = System.Reflection.Assembly.Load("Your Assembly Name");Type t = a.GetType( "form1" );Form f = (Form)Activator.CreateInstance(t);
好奇怪,我把大侠给我的代码Copy 下来进行执行 在执行Type t = a.GetType( "Form1" )后,发现t为null值 我这样改写不知道对吗? System.Reflection.Assembly a = System.Reflection.Assembly.Load("ClassLibrary1"); Type t = a.GetType("Form1"); Form f = (Form)Activator.CreateInstance(t); f.ShowDialog();
下来进行执行 在执行Type t = a.GetType( "Form1" )后,发现t为null值 我这样改写不知道对吗?
System.Reflection.Assembly a = System.Reflection.Assembly.Load("ClassLibrary1");
Type t = a.GetType("Form1");
Form f = (Form)Activator.CreateInstance(t);
f.ShowDialog();
a.GetType("Form1");这个Form1必须是全称,包括命名空间的名称,例如:
a.GetType("ClassLibrary1.Form1");