我可以从HashCode获取对象吗?

时间:2014-11-17 08:26:21

标签: c# wpf binding storyboard hashcode

他们是否可以通过哈希码获取对象???

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

那么请帮助我找到对象或样式或控制模板,其中实际绑定警告即将到来?或者帮助我通过其哈希码找到警告所针对的对象。

以下约束警告即将到来。

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'

如何获得这些警告的来源?任何人都可以帮助我吗?

2 个答案:

答案 0 :(得分:4)

哈希函数是一种方法,你传递一个输入值,它将始终输出相同的值。

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

那就是说,你质疑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);

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

中所述

另外,您可能需要查看this ticket on DevExpress

答案 1 :(得分:2)

哈希码是一种方式,你可以从一个对象获得一个哈希,但不能反过来。