【问题标题】:Cannot add "using System.Windows.Media.Imaging;" in WPF desktop application无法添加“使用 System.Windows.Media.Imaging;”在 WPF 桌面应用程序中
【发布时间】:2014-01-30 19:26:03
【问题描述】:

我需要使用 BitmapImage 类,它是 System.Windows.Media.Imaging 命名空间的一部分。

从 Visual Studio 2012 Express 开始,我从一个 WPF 桌面应用程序项目模板开始,我可以看到相关的 dll,PresentationCore.dll 在引用下。

This link on MSDN 表示这个引用应该足够了。 This thread 表示相同,并强调在 VS2012 中使用典型 wpf 项目模板时默认引用必要的 dll 的事实。

然而,在我后面的 C# 代码中,编译器在我的 using System.Windows.Media.Imaging; 声明中抱怨找不到 Media

这个问题似乎并不少见,但我没有找到解决办法。

更新: 查看 PresentationCore.dll 引用的属性时,我看到版本是 4.0.0.0,运行时版本是 4.0.30319。我正在与 BitmapImage 仅存在于 .net 4.5 的事实建立一个廉价的关系……这可能是对问题的暗示吗?

【问题讨论】:

标签: c# wpf .net-4.5


【解决方案1】:

WPF 项目需要 3 个必需的引用:PresentationCore、PresentationFramework 和 WindowsBase。请参阅 WPF ArchitectureWPF Architecture - and overview ... 。第二个很好地描述了库的内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-01
    • 1970-01-01
    • 2010-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    相关资源
    最近更新 更多