【问题标题】:Call Stack Error - C#调用堆栈错误 - C#
【发布时间】:2012-01-03 05:46:43
【问题描述】:
        // 
        // textEdit1
        // 
        this.textEdit1.Location = new System.Drawing.Point(4, 20);
        this.textEdit1.Name = "textEdit1";
        this.textEdit1.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.HotFlat;
        this.textEdit1.Properties.MaxLength = 15;
        this.textEdit1.Properties.NullValuePrompt = "<Beta Code>";
        this.textEdit1.Properties.NullValuePromptShowForEmptyValue = true;
        this.textEdit1.Properties.PasswordChar = '*';
        this.textEdit1.Size = new System.Drawing.Size(250, 22);
        this.textEdit1.TabIndex = 2;

因此,我收到 5 条警告消息和一个调用堆栈错误,这意味着我无法在设计器模式下查看它。

警告信息:

Warning 1   Object reference not set to an instance of an object.
Warning 2   Object reference not set to an instance of an object.
Warning 3   Object reference not set to an instance of an object.
Warning 4   Object reference not set to an instance of an object.
Warning 5   Object reference not set to an instance of an object.

如果有任何帮助,他将不胜感激。提前致谢。

调用栈:

at DevExpress.XtraEditors.Repository.RepositoryItem.CreateDesigner()
at DevExpress.XtraEditors.Repository.RepositoryItem.FilterProperties(PropertyDescriptorCollection collection)
at DevExpress.XtraEditors.Repository.RepositoryItem.System.ComponentModel.ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
at System.ComponentModel.TypeDescriptor.MergedTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
at System.ComponentModel.TypeDescriptor.GetPropertiesImpl(Object component, Attribute[] attributes, Boolean noCustomTypeDesc, Boolean noAttributes)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.GetPropertiesHelper(IDesignerSerializationManager manager, Object instance, Attribute[] attributes)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertyAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement, CodePropertyReferenceExpression propertyReferenceEx, Boolean reportError)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)

【问题讨论】:

  • this.textEdit1 存在吗?调用堆栈错误是什么?
  • @rlemon 我会把它添加到主帖中
  • @JohnSaunders 不,但感谢发帖。
  • @Neel:“不”什么?这不是 NullReferenceException?

标签: c# .net warnings compiler-warnings windows-forms-designer


【解决方案1】:

您只是忘记向其中一个对象提供数据。确保所有需要数据的来源和对象都得到它。

首先使用 try 和 catch 省略一些代码,如果可以通过检查调用堆栈来查看错误的来源。

【讨论】:

    【解决方案2】:

    我怀疑 TextEdit.Properties 对象没有根据生成的警告数进行实例化(对 Properties 属性的 5 次引用的 5 次警告)。快速的 Google 搜索显示其他一些人在使用 DevExpress 控件时遇到了这个问题,但我找不到任何解决方案。

    您应该尝试以下几点:

    1. 确保您已引用所有适用的 DevExpress DLL。
    2. 尝试从表单/控件/等中删除您的 TextEdit 控件,然后重新添加。
    3. 将您的问题提交给DevExpress support center。他们通常反应迅速。

    【讨论】:

      猜你喜欢
      • 2017-08-15
      • 2010-11-09
      • 2015-04-22
      • 1970-01-01
      • 1970-01-01
      • 2019-11-25
      • 1970-01-01
      • 2011-03-27
      • 2016-11-11
      相关资源
      最近更新 更多