【问题标题】:PostSharp get_Property errorPostSharp get_Property 错误
【发布时间】:2017-07-21 14:39:30
【问题描述】:

我正在使用 Telerik 的 PostSharp 和 RadGridView。有些列有使用 DataTypeConverter 的自定义数据,我使用它从名为 Name 类型为 AdvisableDictionary<Tkey, TValue> 的属性中加载值。

网格有过滤按钮,点击后会显示一个带有类似 Excel 过滤选项的弹出窗口。

但是,当我单击此按钮时,我收到一条错误消息,提示 Failed to compare two elements in the array. 这仅适用于具有此类数据的列。我对 PostSharp 没有太多经验,但我认为这是由 PostSharp 生成的。

这是 PostSharp 输出窗口中的最后几行,在它引发异常之前:

The thread 0x3964 has exited with code 0 (0x0).

The thread 0x364 has exited with code 0 (0x0).

Step into: Stepping over non-user code 'TranslatableObject.get_Name'

Step into: Stepping over non-user code 'TranslatableObject.<Name>c__Binding1.GetValue'

Step into: Stepping over non-user code 'TranslatableObject.<Name>c__Binding1.get_LocationInfo'

Step into: Stepping over non-user code 'TranslatableObject.<Name>c__Binding.GetValue'

我可以做些什么来解决这个错误?

【问题讨论】:

  • 能否请您在此处粘贴异常的堆栈跟踪和完整消息?如果您分享一个重现此行为的最小示例,也将有助于确定原因。
  • 谢谢! Here 是一个示例项目。我在下面的答案中找到了一个解决方案。

标签: c# dictionary telerik postsharp radgridview


【解决方案1】:

您可以创建一个类来继承 AdvisableDictionary 并实现 IComparable。

public class AdvisableDictionary: IComparable
{
    //here add the code from your heart
}

HERE 1

HERE 2

所以在 FilterPopup 的 FilterConfirmed 事件中很简单,您需要更正过滤器描述符的值。

就是这样。

这是一个示例prj。请看一下。尽情享受 C# 编程吧。

这是我的解决方案,需要尝试,成为老板,努力尝试,快乐:)

【讨论】:

    【解决方案2】:

    我想出了一个解决方案:AdvisableDctionary 没有实现用于对项目列表进行排序的 IComparable。

    我创建了一个类来继承AdvisableDictionary 并实现IComparable 和Filter Popup 的FilterConfirmed 事件。

    我更正了过滤器描述符的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多