[英]System.drawing namespace not found under console application
I selected console application as my C# project.我选择控制台应用程序作为我的 C# 项目。 But the imports that seemed to work under Windows Form project don't seem to work here.
但是似乎在 Windows 窗体项目下工作的导入在这里似乎不起作用。 It says that the drawing namespace does not exist.
它说绘图命名空间不存在。
using System.Drawing;
using System.Drawing.Imaging;
My problem is that I need to have the bitmap class.我的问题是我需要有位图类。 I am trying to make a command line app that does bitmap manipulations to a image.
我正在尝试制作一个对图像进行位图操作的命令行应用程序。 That's why I didn't choose my project to be a Windows Form one.
这就是为什么我没有将我的项目选择为 Windows Form one。
You need to add a reference to System.Drawing.dll
.您需要添加对
System.Drawing.dll
的引用。
As mentioned in the comments below this can be done as follows: In your Solution Explorer (Where all the files are shown with your project), right click the "References" folder and find System.Drawing on the .NET Tab.正如下面的评论中提到的,这可以按如下方式完成:在您的解决方案资源管理器中(所有文件都显示在您的项目中),右键单击“参考”文件夹并在 .NET 选项卡上找到 System.Drawing。
If you are using Visual Studio 2010 or plus then check the target framework that is it .Net Framework 4.0 or .Net Framework 4.0 Client Profile.如果您使用的是 Visual Studio 2010 或 plus,请检查目标框架是 .Net Framework 4.0 或 .Net Framework 4.0 Client Profile。 then change is to .Net Framework 4.0.
然后更改为 .Net Framework 4.0。
You need to add reference this .dll file (System.Drawing.dll) to perform drawing operations.
您需要添加引用此 .dll 文件 (System.Drawing.dll) 以执行绘图操作。
If it is OK then follow these steps to add reference to System.Drawing.dll
如果没问题,请按照以下步骤添加对
System.Drawing.dll
引用
Solution Explorer
, right-click on the project node
and click Add Reference.
Solution Explorer
,右键单击project node
并单击Add Reference.
System.Drawing.dll
to reference, then click OK.System.Drawing.dll
,然后单击“确定”。For,Adding System.Drawing Follow some steps: Firstly, right click on the solution and click on add Reference.对于,添加 System.Drawing 遵循一些步骤: 首先,右键单击解决方案,然后单击添加引用。 Secondly, Select the .NET Folder.
其次,选择 .NET 文件夹。 And then double click on the Using.System.Drawing;
然后双击 Using.System.Drawing;
安装包 System.Drawing.Common
Add reference .dll file to project.将参考 .dll 文件添加到项目。 Right, Click on Project reference folder --> click on Add Reference -->.Net tab you will find System.Drawing --> click on ok this will add a reference to System.Drawing
右键,单击项目引用文件夹 --> 单击添加引用 --> .Net 选项卡,您将找到 System.Drawing --> 单击确定,这将添加对 System.Drawing 的引用
Install this library from Nuget从 Nuget 安装这个库
System.Drawing.Common
https://www.nuget.org/packages/System.Drawing.Common/6.0.0 https://www.nuget.org/packages/System.Drawing.Common/6.0.0
Target framework
Target framework
.Net framework 4.0 Client Profile
then change it to .Net Framework 4.0
.Net framework 4.0 Client Profile
则将其更改为.Net Framework 4.0
It works now它现在有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.