'C# System.Drawing Reference issue

I'm a total noob when it comes to C#, C++ (C anything) and visual studio.

I'm trying to draw a table over a chart using

public override void OnPaintChart(PaintChartEventArgs args)
        {
            Graphics gr = args.Graphics;

            Font font = new Font("Arial", 10);
    
            for (int i = 0; i < KeyLevel.Length; i++)
                gr.DrawString(KeyLevel[i].ToString(), font, Brushes.LightGray, 20, 23 * i + 30);
        }

but i'm getting the following error: "The type 'Graphics' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc6......."

If I right click my project and go to Add > References, the only available system.drawing is showing as version 4.0.0.0.

I've updated visual studio and updated .net.

I've stated/referenced?? (dont know terminology)

using System;
using System.Drawing;

at the beginning of my script.

How do i get version 6.0.0.0?

I'm really stuck with this.

Thanks in advance.



Solution 1:[1]

Solution if anybody runs into same problem.

Update to Visual Studio 2022.

Update .net

In visual studio, right click project > Manage NuGet Packages

Search drawing and install package.

Swear at Microsoft for making life hard.

Done.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ABB1987