【发布时间】:2012-07-21 09:05:21
【问题描述】:
我收到以下编译时错误:
The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)
这是我的代码:
BitmapImage img = new BitmapImage();
【问题讨论】:
我收到以下编译时错误:
The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)
这是我的代码:
BitmapImage img = new BitmapImage();
【问题讨论】:
今天(2020 年)它是 nuGet 包System.Drawing.Common.dll。
添加它:右键单击项目名称(在解决方案资源管理器中)->“管理 NuGet 包”-> 选择顶部的“浏览”标签--> 搜索“System.Drawing.Common”-> 安装它.
【讨论】:
您必须将System.Drawing 添加到您的引用中,以便在解决方案中
Explorer 右键单击 References 并单击 Add References 并在
程序集找到System.Drawing 并单击确定
【讨论】:
添加 PresentationCore 作为参考。
PresentationCore 程序集出现在您项目的引用列表中。
在文件顶部为 System.Windows.Media.Imaging 命名空间添加 using 指令,这是 BitmapImage 所在的位置。
using System;
using System.Windows.Media.Imaging;
【讨论】:
BitmapImage 而不是 Bitmap
也许你需要补充:
using System.Windows.Media.Imaging;
【讨论】:
System.Drawing
System.Drawing 不正确 - BitmapImage 位于 System.Windows.Media.Imaging 命名空间中,并且位于 PresentationCore.dll 中,该名称应位于 .NET 3 及更高版本的 GAC 中。