Form fm=(Form)Assembly.Load(path).CreateInstance(name); 说明你这句fm的对象是个NULL->说明(Form)Assembly.Load(path).CreateInstance(name)函数执行没成功. name是你想要反射到的窗体类的类名,检查下是否写对了?
Form fm=(Form)Assembly.Load(path).CreateInstance(name); 说明这个为空 看个是不是没写对@
Type type = Type.GetType("WindowsApplication1.Form1, WindowsApplication1"); if (type != null) { Form from = type.Assembly.CreateInstance(type.FullName) as Form; }
说明你这句fm的对象是个NULL->说明(Form)Assembly.Load(path).CreateInstance(name)函数执行没成功.
name是你想要反射到的窗体类的类名,检查下是否写对了?
说明这个为空
看个是不是没写对@
if (type != null)
{
Form from = type.Assembly.CreateInstance(type.FullName) as Form;
}