Search code examples
c#visual-studioreferencesystem.drawing

can't add System.Drawing.dll reference


Ok, so I'm on this bug for the last 4 hours and I dont know what to do..

I'm using Visual Studio Community 2017 and I opened Consol App(.net core) project. also I'm working on windows 8.1 OS.

I wanted to use Image from the System.Drawing namespace and it keeps giving me that error: "the type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)"

I downloaded the System.Drawing.dll from https://www.dllme.com/dll/files/system_drawing_dll.html (to the desktop) and then right click on the right project->add->Reference..->Browse..->System.Drawing.dll->OK then I saw in the project (in the Solution Explorer) in the project dependencies->Assemblies->System.Drawing so I guess it works right?!

I'm still getting the same error and can't use the System.Drawing namespace, any suggestions?

using System;
using System.Net.Sockets;
using System.Drawing;
namespace client2
{
  class Program
  {
    static void Main(string[] args)
    {
        try
        {

            //read image
            Image image = new Image("C:\\image\\amir.jpg");
        }
    }
}

}


Solution

  • System.Drawing is not part of the cross-platform parts of .NET (Core). It depends on GDI+ which is part of Windows. There are plenty of alternatives out there.

    Aside: Never download DLLs from an untrusted source.