Home > Enterprise >  Using classes in Class library project
Using classes in Class library project

Time:11-07

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
        }
    }
}

CodePudding user response:

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.

  • Related