【问题标题】:Can I get object from HashCode?我可以从 HashCode 中获取对象吗?
【发布时间】:2015-01-14 02:39:06
【问题描述】:

他们有什么方法可以从哈希码中获取对象吗???

实际上问题是我在我们的应用程序中发现了一些绑定警告,并且每个警告都有相同的源哈希码。我尝试按源名称和目标名称搜索,但没有找到这样的东西。

所以请帮助我找到实际绑定警告即将到来的对象或样式或控件模板?或者帮助我通过哈希码找到警告即将到来的对象。

以下绑定警告即将到来。

System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='56844144'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='64558826'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='16230876'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='40603406'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='47611344'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='6250841'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='25349309'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='35348398'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='4124450'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='21506238'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'
    System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='SkipToFill'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='33003048'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='DevExpress.Xpf.Editors.ErrorControl: DevExpress.Xpf.Grid.GridCellValidationError'; TargetElement.HashCode='18846426'; TargetElement.Type='DevExpress.Xpf.Editors.ErrorControl'

如何获得这些警告的来源?谁能帮帮我???

【问题讨论】:

  • 您能在此处发布绑定错误吗?
  • 你好彼得,看到这些异常即将到来......
  • 实际上这些是警告,但我将警告视为错误。我也必须删除警告。

标签: c# wpf binding storyboard hashcode


【解决方案1】:

散列函数是一种方式,你向它传递一个输入值,它总是会输出相同的值。

所以不,你不能逆向,即你不能反过来(从哈希生成对象)。 哈希函数用于将任意大小的数字数据映射到固定大小的数字数据,因此存在哈希码计算固有的信息丢失。

也就是说,您质疑X-Y problem 的气味。我认为您想调试为什么会在 wpf 中发生问题,并作为一种方法来确定您正在尝试使用哈希码对其进行调试。

解决这个问题的一种方法是找出所有对象的hashcode,并将它们与攻击性hashcode进行比较。

您可以使用以下代码来做到这一点:

private string GetStoryBoardNameByHashCode(int hashCode)
{
    foreach (DictionaryEntry resource in Resources)
    {
        if (resource.Value is Storyboard)
        {
            if (resource.GetHashCode() == hashCode)
                return ((Storyboard) resource.Value).Name;
        }
    }
    return String.Empty;
}

并如下执行,如this answer中所述:

    string storyBoardName = GetStoryBoardNameByHashCode(65981734);

另一种可能性是Begin 部分缺少Stop,如this answer 中所述

另外,您可能想看看this ticket on DevExpress

【讨论】:

    【解决方案2】:

    哈希码是一种方式,您可以从对象中获取哈希值,但反之则不行。

    【讨论】:

    • 但是我怎样才能得到那个对象???..我知道从一个对象我可以通过使用 GetHashCode() 方法得到它的 hashCode。但就我而言,我想反过来。
    • “但不是相反”。你不能。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-07
    • 1970-01-01
    • 2020-07-16
    • 2022-11-06
    • 2015-03-10
    • 1970-01-01
    • 2012-05-31
    相关资源
    最近更新 更多