我像这样扩展了一个控件
public partial class NewControl : OriginalControl
{
public NewControl()
{
}
}
并将 MyForm.Designer.cs 中的这些行从
private OriginalControl control1;
this.control1 = new OriginalControl();
到
private NewControl control1;
this.control1 = new NewControl();
但是,当我在设计器中打开表单时,会出现此错误:
无法加载设计器。检查源代码是否有语法错误,并检查是否所有引用都可用。
ICSharpCode.FormsDesigner.FormsDesignerLoadException:System.ComponentModel.Design.Serialization.CodeDomSerializerException:找不到类型“NewControl”。请确保引用了包含此类型的程序集。如果此类型是您的开发项目的一部分,请确保已使用当前平台或任何 CPU 的设置成功构建项目。在 System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design .Serialization.CodeDomSerializer。
System.ComponentModel.Design.Serialization.CodeDomSerializerException:变量“control1”未声明或从未分配。在 System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design .Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
在 ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadDesigner()
在 ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadAndDisplayDesigner() 在 ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadInternal(OpenedFile 文件,流流) 在 ICSharpCode.SharpDevelop.Gui.AbstractViewContentHandlingLoadErrors.Load(OpenedFile 文件,流溪流)
我如何错误地扩展我的控制权?