Search code examples
c#imagevisual-studiosystem.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:

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

Add references window


Solution

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

    Assemblies

    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