主界面动态调用dll,如:
//加载控件
Assembly assembly = Assembly.LoadFrom(@"C:\Documents and Settings\king.xu.GRANDSYS-DOMAIN\桌面\aa\WindowsApplication2
\bin\Debug\WindowsControlLibrary1.dll");
//获得类(型)
Type type = assembly.GetType("WindowsControlLibrary1.UserControl1", false, true);
//设置筛选标志
BindingFlags bflags = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
//调用构造函数并获得对象
Object obj = type.InvokeMember("WindowsControlLibrary1", bflags | BindingFlags.CreateInstance, null, null, null);
UserControl userControl11 = null;
//userControl11 = new WindowsControlLibrary1.UserControl1();
userControl11 = (UserControl)obj;
this.SuspendLayout(); //这个方法和稍后的ResumeLayout方法有什么作用???
userControl11.Location = new System.Drawing.Point(16, 16);
userControl11.Name = "userControl11"; //这个name有什么意义?一般会在哪用到???
userControl11.Size = new System.Drawing.Size(400, 208);
//this.Controls.Add(userControl11);
//this.ResumeLayout(false);