C# 找不到“位图”(您是否缺少 using 指令或程序集引用?)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11607277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'Bitmap' could not be found (are you missing a using directive or an assembly reference?)
提问by sara brown
I am getting the following compile-time error:
我收到以下编译时错误:
The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)
Here is my code:
这是我的代码:
BitmapImage img = new BitmapImage();
回答by Dane Balia
Perhaps you need to add:
也许你需要添加:
using System.Windows.Media.Imaging;
回答by harini bangalore
Add PresentationCore as a reference.
添加 PresentationCore 作为参考。
How-to:
如何:
- Click the .NET tab.
- Locate and click the PresentationCore item from the list.
- Click the OK button.
- 单击 .NET 选项卡。
- 从列表中找到并单击 PresentationCore 项。
- 单击确定按钮。
Result:
结果:
The PresentationCore assembly appears in the References list for your project.
PresentationCore 程序集出现在项目的参考列表中。
Finally:
最后:
Add a using directive for the System.Windows.Media.Imaging namespace at the top of the file, which is where BitmapImagelives.
为文件顶部的 System.Windows.Media.Imaging 命名空间添加 using 指令,该命名空间就是所在的位置BitmapImage。
using System;
using System.Windows.Media.Imaging;
回答by LA SN
You have to add System.Drawingto your references so in solution
Explorer rightclick on References and click on Add References and in
assemblies find System.Drawingand click OK
您必须添加System.Drawing到您的引用,因此在解决方案资源管理器中右键单击引用并单击添加引用,然后在程序集中找到System.Drawing并单击确定

