1

I created a .NET Standard Class Library project, but when I tried using the System.Drawing class, everything behaved as if it wasn't there. I can't use anything in the class. Why is that happening and how can it be fixed?

using System;
using System.Drawing;

namespace Blueberry
{
    public class GameObject
    {
        public void Sprite()
        {
            Image img; //Error: Type Image not found
        }
    }
}
  • 1
    did you add the reference? – fmansour Nov 07 '21 at 13:02
  • For .netstandard (and .net core), use System.Drawing.Common : https://stackoverflow.com/questions/46722409/cannot-find-bitmap-class-in-class-library-net-standard/46722736 – Yom B Nov 07 '21 at 13:06

1 Answers1

2

System.Drawing is a Windows only component and as such requires .NET Framework (or a compatibility pack).

If you want to use .NET Standard, you can add the System.Drawing.Common Nuget Package to your project.

nvoigt
  • 75,013
  • 26
  • 93
  • 142