- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
将 ListBox 的 ItemsSource 绑定(bind)到 ObservableCollection<object>
时出现此异常.
该集合混合了 {DependencyPropertyChangedEventArgs, EventEntry}
我偷看了DependencyPropertyChangedEventArgs
并发现:
public struct DependencyPropertyChangedEventArgs
{
...
public override bool Equals(object obj)
{
return this.Equals((DependencyPropertyChangedEventArgs)obj); <- huge cast right here?
}
}
EventEntry 代码:
public class EventEntry
{
public EventEntry(string name)
{
Name = name;
}
public string Name { get; private set; }
}
当我阅读偷看的代码时,它会爆炸。
这样对吗?
最佳答案
确认错误,重现:
[Test]
public void Repro()
{
var args = new DependencyPropertyChangedEventArgs(UIElement.IsEnabledProperty, false, true);
Assert.Throws<InvalidCastException>(() => args.Equals(1));
}
Confirmed bug in the implementation: (below code is from reference source)
public override bool Equals(object obj)
{
return Equals((DependencyPropertyChangedEventArgs)obj);
}
关于c# - WindowsBase.dll 中发生类型为 'System.InvalidCastException' 的第一次机会异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23585430/
我正在使用 OpenXML SDK 将数据写入 excel 文件。现在,这在我的开发机器上运行良好。 上周,我们将代码带到生产服务器,正如预期的那样,它没有安装 OpenXML DLL。为了使其正常工
我正在尝试在 Visual Studio 2013 中加载解决方案,但我收到了这条消息: 当我单击“确定”时,它会显示另一条错误消息: Attempted re-targeting of the pr
我遇到了奇怪的编译时错误: 项目文件必须在引用列表中包含 .NET Framework 程序集“WindowsBase、PresentationCore、PresentationFramework”。
我是 StackOverflow 和一般编程的新手,如果我没有正确解释事情,请提前道歉。 我收到错误信息: An unhandled exception of type 'System.StackOv
我正在使用 WPF 创建一个应用程序,并且我有一个带有 Awesomium WebControl 的 UserControl。 当我将此 UserControl 的副本添加到我的主窗口时,我从 Win
将 ListBox 的 ItemsSource 绑定(bind)到 ObservableCollection 时出现此异常. 该集合混合了 {DependencyPropertyChangedEven
我有一个 .NET 4.0 WPF 项目。 当我打开 FileDialog 时,选择一些文件并按 OK 按钮,然后我在输出窗口中看到此错误: WindowsBase.dll 中发生了“System.C
我在 ASP.NET 应用程序中看到难以理解的编译错误。 Project file must include the .NET Framework assembly 'WindowsBase, Pre
今天早上买了一台新机器并安装了 Visual Studio 2012,这是我在启动时遇到的错误 --------------------------- Microsoft Visual Studio
我目前正在编写一个从文档中获取 XML 并将其显示在网页上的上传系统。 我面临的问题是,每当我添加网站的 XML 提取部分时,编译器都会返回标题中提到的错误。我已经通过手动和下拉菜单添加了 Windo
我的 View 模型中有这个属性。 public bool IsKWH { get { return _isKwh; } set { if (value.Equ
我目前正在尝试打开一个带有 System.Windows 的窗口。我包含了三个汇编引用: C:\Program Files (x86)\Reference Assemblies\Mic
我在 Windows 窗体应用程序中使用 C# 使用 WPF。 跟进问题。 Adding a collection of solid,dashed lines pen to a combo box 错
现在我有一个奇怪的。这只发生在 Windows XP 下的独立构建(调试/发布,无关紧要)。在 Windows 7 下工作得很好。无论如何,因为我必须确保该应用程序在 XP 下工作,所以我不得不做一些
我是一名优秀的程序员,十分优秀!