简体   繁体   中英

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:

"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".

I have already went to Project>Add Reference>COM>System.Drawing.dll>Select>OK to add it but the error is still there.

添加引用窗口

Don't use the "COM" section in that dialog. Use "Assemblies" instead:

组件

Note how this gives newer versions (4.0) instead of old versions (2.0 / 2.4).

If there is no "Assemblies" section, check that you really created a C# .NET Framework project. Likely you chose C# .NET Core.

If you want to stick with .NET Core, use the Nuget package System.Drawing.Common

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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