简体   繁体   English

无法在 C# 控制台应用程序中添加 System.Drawing 命名空间

[英]Can't add System.Drawing namespace in C# console application

I'm trying to add the System.Drawing namespace in my C# console application but when I go to use it's 'Image' type, I get the error:我试图在我的 C# 控制台应用程序中添加 System.Drawing 命名空间,但是当我 go 使用它的“图像”类型时,我得到了错误:

"The type name 'Image' could not be found it the namespace 'System.Drawing'. This type has been forwarded to assembly System.Drawing.Common, Version=4.0.20, Culture=neutral, Consider adding reference to that assembly". “在命名空间 'System.Drawing' 中找不到类型名称 'Image'。此类型已转发到程序集 System.Drawing.Common,版本 = 4.0.20,文化 = 中性,考虑添加对该程序集的引用” .

I have already went to Project>Add Reference>COM>System.Drawing.dll>Select>OK to add it but the error is still there.我已经去 Project>Add Reference>COM>System.Drawing.dll>Select>OK 添加它,但错误仍然存在。

添加引用窗口

Don't use the "COM" section in that dialog.不要使用该对话框中的“COM”部分。 Use "Assemblies" instead:改用“程序集”:

组件

Note how this gives newer versions (4.0) instead of old versions (2.0 / 2.4).请注意这是如何提供更新版本 (4.0) 而不是旧版本 (2.0 / 2.4)。

If there is no "Assemblies" section, check that you really created a C# .NET Framework project.如果没有“程序集”部分,请检查您是否真的创建了 C# .NET 框架项目。 Likely you chose C# .NET Core.您可能选择了 C# .NET Core。

If you want to stick with .NET Core, use the Nuget package System.Drawing.Common如果您想坚持使用 .NET 内核,请使用 Nuget package System.Drawing.Common

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM