我在尝试在 Visual Studio 2022 中使用用户控件时收到此消息
X
Failed to create component 'CtrPersonCard The error
message follows
'System.MissingMethodException: Constructor on type 'DVLDNew.CtrPersonCard' not found.
at System.Runtime Type.CreateInstancelmpl(BindingFlags bindingAttr. Binder binder Object[] as, Cultureinfo culture Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator CreateInstance(Type type, BindingFlags bindingAttr Binder binder, Object[] args, CultureInfo culture,
Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr. Binder binder Object[] args, CultureInfo culture)
at
System.ComponentModel.Design.DesignSurface.CreateInstanc e(Type type)
at
Microsoft VisualStudio. Design. VSDesignSurface.CreateInstance( Type type)
at
System.ComponentModel.Design.DesignerHost System.Compo nentModel.Design. IDesignerHost.CreateComponent(Type component Type, String name)
at
System.Drawing.Design.Toolboxitem.CreateComponentsCore(1 DesignerHost host)
at
System.Drawing.Design. Toolboxltem.CreateComponentsCore(1 DesignerHost host, IDictionar
尝试使用c#进行用户控制 但我在尝试使用它时收到了这条消息 我可以在工具箱中看到控件,但高于消息 请帮忙
检查您的用户控件类是否具有构造函数。 像这样:
public CtrPersonCard()
{
InitializeComponent();
}
如果构造函数存在,那么您可能正在调用另一个用户控件,或者您的代码中的命名空间是错误的...