我像这样扩展了一个控件
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.DeserializeStatementToInstance(IDesignerSerializationManager 经理,CodeStatement声明)at System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager 经理,对象代码对象)at ICSharpCode.FormsDesigner.Services.ProjectResourcesComponentCodeDomSerializer.Deserialize(IDesignerSerializationManager 经理,对象代码对象)at System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager 经理,对象代码对象)at ICSharpCode.FormsDesigner.Services.ProjectResourcesComponentCodeDomSerializer.Deserialize(IDesignerSerializationManager 经理,对象代码对象)at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager manager,String name,CodeStatementCollection语句)
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 经理,CodeStatement声明)
在 ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadDesigner()
在 ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadAndDisplayDesigner() 在 ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadInternal(OpenedFile 文件,流媒体流) ICSharpCode.SharpDevelop.Gui.AbstractViewContentHandlingLoadErrors.Load(OpenedFile 文件,流媒体流)
我如何扩展控制错误?
答案 0 :(得分:1)
这可能纯粹是出现这两个控件的命名空间的问题。查看完全限定的类名是否恰好解决了您的问题。