文件名,窗体名,参数
private int Run_WinForm(string filename, string myfrmname, DataTable mydtmsg)
{
Assembly vAssembly = null;
if (string.IsNullOrEmpty(filename) == true)
{
vAssembly = Assembly.GetExecutingAssembly();
}
else
{
if (System.IO.File.Exists(filename) == true)
{
vAssembly = Assembly.LoadFrom(filename);
}
else
{
cwfIosys.ioCtrl.MsgShow("程序集文件不存在!\r\n" + filename);
return 0;
}
}
System.Globalization.CultureInfo gcnull = null; object[] objnull = null;
Binder binull = null;
object vTemp = null;
object[] objstr = new object[1];
objstr[0] = mydtmsg;
vTemp = vAssembly.CreateInstance(myfrmname, true, BindingFlags.Default, binull
, objstr, gcnull, objnull);
try
{
if (vTemp == null && appCtrl.appAssembly != null)
{
vAssembly = appCtrl.appAssembly;
vTemp = vAssembly.CreateInstance(myfrmname, true, BindingFlags.Default, binull
, objstr, gcnull, objnull);
}
else
{
if (appCtrl.appAssembly == null)
{
cwfIosys.ioCtrl.MsgShow("appCtrl.appAssembly is Null"
+ "\r\n Assembly vAssembly"
+ "\r\n vAssembly = Assembly.GetExecutingAssembly();" +
"run_winform!", "No vAssembly!", 2, 1500);
}
}
}
catch (Exception cw)
{
if (cw.Message.IndexOf(myfrmname) >= 0)
{
vTemp = vAssembly.CreateInstance(myfrmname);
}
else
{
MessageBox.Show(cw.Message);
cwfIosys.ioCtrl.MsgShow(cw.Message + "\r\n" + cw.GetBaseException().ToString());
}
}
if (vTemp != null)
{
// ((System.Windows.Forms.Form)vTemp).MdiParent = appCtrl.appMainfrom;
((System.Windows.Forms.Form)vTemp).Show();
// ((System.Windows.Forms.Form)vTemp).Name = wname.Replace(".", "_");
// appCtrl.appMainfrom.Load_WorkToolStripStatus(wname.Replace(".", "_"), title);
// ((System.Windows.Forms.Form)vTemp).FormClosed += new System.Windows.Forms.FormClosedEventHandler(appCtrl.frmsys_FormClosed);
return 1;
}
return 0;
}