C# using System.Drawing.Common; gives error name 'Common' does not exist in the namespace 'System.Drawing'

249 views Asked by At

I am having a C# WPF desktop app project on .NET6 in Visual Studio.

Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWPF>true</UseWPF>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Drawing.Common" Version="7.0.0" />
  </ItemGroup>
</Project>

I've installed the package System.Drawing.Common from nuget for this project. The package seems to be in the project dependencies. There is a <PackageReference> to it. This strange error

CS0234
The type or namespace name 'Common' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)

makes me crazy.

I don't understand if it's some weird conflict with the namespace of the package System.Drawing or something else. Visual Studio as always gives no clues, no solutions. ChatGPT has nothing to say about this except that I should add <PackageReference> to it. Forums don't seem to have anything about this issue. Please could you help me understand. I am new to C#. It is so strange I struggle to simply add a pretty standard package to a very simple project.

0

There are 0 answers