我有三个项目(项目1,项目2和项目3)都在一个解决方案中。
每个项目都有自己的窗体(C#)。我写我的代码项目3
我要的是列出所有的项目在一个列表框形成名称:
这里是我的代码:从列表框中的三个项目获取表单名称
private void GetFormNames()
{
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
{
AppDomain.CurrentDomain.Load(a.FullName);
foreach (Type t in a.GetTypes())
{
if (t.BaseType == typeof(Form))
{
Form f = (Form)Activator.CreateInstance(t);
string FormText = f.Text;
string FormName = f.Name;
checkedListBox1.Items.Add("" + FormText + "//" + FormName + "");
}
}
}
}
我'收到此错误:
No parameterless constructor defined for this object.
错误信息是非常明确的IMO .. –