日期:2014-05-17  浏览次数:20865 次

c# 未将对象引用设置到对象的实例

------解决方案--------------------
看了,代码修改起来不算太难:

public static void CreateForm(string filePath,  string strName, string namespaceName, Form MdiParentForm)
        {
            int Index = strName.LastIndexOf(".");
            string formName = strName.Substring(Index + 1);
            if (!ShowChildForm(formName, MdiParentForm))
            {
                string path = namespaceName;
                string name = strName;
                Assembly assembly = Assembly.LoadFrom(filePath);
                Form fr = (Form)assembly.CreateInstance(name);
                fr.MdiParent = MdiParentForm;
                fr.Width = 1040;
                fr.Height = 755;
                fr.FormBorderStyle = FormBorderStyle.None;
                fr.StartPosition = FormStartPosition.Manual;
                fr.Show();
            }
        }

调用的时候

                if (this.TOOLS.SelectedNode.Name == "Work")
                {
                    CreateForm(Application.ExecutablePath,"WindowsApp" + "." + Program.userGroup, "WindowsApp", this);
                }
                else
                {
               &