正好用到了简单记录一下查找的解决方案
一般反射都是这样用,只能用来构建无参数的窗体
var assembly = Assembly.LoadFrom(Path.Combine(Application.StartupPath, "GXT.QualificationAutoReference.DLL"));
var frm = assembly.CreateInstance("GXT.QualificationAutoReference.View.FrmMain");
if (frm!=null)
{
if (frm is Form autoReferenceFrm)
{
autoReferenceFrm.ShowDialog();
}
}
``
有参数的时候有几个参数,ObjArray就写几个,顺序类型一致即可
var assembly = Assembly.LoadFrom(Path.Combine(Application.StartupPath, "GXT.QualificationAutoReference.DLL"));
object[] ObjArray = new object[3];
ObjArray[0] = BidQualificationConsts.BidEditPath;
ObjArray[1] = BidQualificationConsts.EQ_BidFileIndexItemList;
ObjArray[2] = this;
var frm = assembly.CreateInstance("GXT.QualificationAutoReference.View.FrmMain",true,BindingFlags.Default,null,ObjArray,null,null);
if (frm!=null)
{
if (frm is Form autoReferenceFrm)
{
autoReferenceFrm.ShowDialog();
}
}