C# - CS0103 : The name 'Brushes' does not exist in current context

Jacques Prinsloo 0 Reputation points
2025-08-07T16:50:43.21+00:00

Hi

I'm new to C# and trying to plot a graph in IX developer, got the following code of the web, all compiles fine except for the pens and brushes colors which gives a CS0103: Error saying they don't exist in the current context, can anyone guide me as to what the issue is?

(Got a smaller issue when using bmp.Save but found a way for that.)

User's image

Developer technologies | C#
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 123.6K Reputation points
    2025-08-07T19:14:52.97+00:00

    Try to add a package:

    • Right-click the project in Solution Explorer, select “Manage NuGet Packages”,
    • Go to Browse tab, search for System.Drawing,
    • Select and install the System.Drawing.Common package.

    However, if you are using .NET Framework instead of .NET, then:

    • Right-click the project in Solution Explorer, select Add, Refererence,
    • Go to Assemblies, select System.Drawing.
    0 comments No comments

  2. Adiba Khan 245 Reputation points Microsoft External Staff
    2025-08-08T10:05:37.13+00:00

    Here are the most likely causes and solutions you can try out:

    1.      Missing reference to System.Drawing.Common-

    In newer .Net versions (especially .Net core, .Net 5,6,or later) the system.drawing namespaces does not come included by default.Manually Install of package is required.

    Fix:

    Open your terminal or package manager console and run:

    Dotnet add package System.Drawing.Common

    Or in Visual Studio:

    ·         Right click on your project-> Manage NuGet Packages

    ·         Search for System.Drawing.Common

    ·         Click Install

    ·         Then rebuild your project

     

    2.      Ensure project Targets Windows-

    As of .Net6 and above System.Drawing.Common is only supported on windows by default

    Add this to your .csproj file if you are using .Net 6 or later:

    <PropertyGroup>

    <TargetFramework>net6.0-windows</TargetFramework>

    <UseWindowsForms>true</UseWindowsForms>

    </Propertygroup>

     

     


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.