'Image' could not be found in the namespace 'System.Drawing'

Jeff Gaines 351 Reputation points
2023-07-30T08:40:07.4333333+00:00

As part of my efforts to VS 2022 I am trying to convert my .NET 3.5 projects to NET 7.

The first two converted fine but the third, which is a dll of images, throws up:

'Image' could not be found in the namespace 'System.Drawing'

I Googled for the error and ended up at NuGet and downloaded a 116 KB zip file which expanded to 58,506 files amounting to 785 MB. Incidentally it has been zipped so it expands to "D:\Data\Downloads\runtime-main\runtime-main" so several files cannot be unzipped because the path is too long.

I cannot find "System.Drawing.Common.dll" in those files nor any way to produce it from them. I use "System.Drawing" a lot so this is going to be a long term issue.

Why doesn't MSFT make this dll available for installation as this must be causing problems for many people?

Is there an easier solution to this issue?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,442 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,296 questions
{count} votes

Accepted answer
  1. P a u l 10,751 Reputation points
    2023-07-30T10:36:28.69+00:00

    Between .NET 3.5 and .NET 7 the System.Drawing now has to be installed as a separate NuGet package.

    Are you downloading the package from the NuGet site? If you are then you don't need to - there's a built in package manager in Visual Studio. Right click your project, go to "Manage NuGet packages...", click on the "Browse" tab at the top and then search for "System.Drawing.Common". The first option should be a package published by Microsoft. Click that and then "Install" on the right hand side.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.