简体   繁体   English

C# System.Drawing参考问题

[英]C# System.Drawing Reference issue

I'm a total noob when it comes to C#, C++ (C anything) and visual studio.当涉及到 C#、C++(C 任何东西)和视觉工作室时,我完全是个菜鸟。

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......."但我收到以下错误: “类型‘Graphics’在未引用的程序集中定义。您必须添加对程序集‘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.如果我右键单击我的项目和 go 以添加 > 引用,唯一可用的 system.drawing 显示为版本 4.0.0.0。

I've updated visual studio and updated .net.我已经更新了 visual studio 并更新了 .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?我如何获得版本 6.0.0.0?

I'm really stuck with this.我真的坚持这个。

Thanks in advance.提前致谢。

Solution if anybody runs into same problem.如果有人遇到同样的问题,请解决。

Update to Visual Studio 2022.更新到 Visual Studio 2022。

Update .net更新 .net

In visual studio, right click project > Manage NuGet Packages在 Visual Studio 中,右键单击项目 > 管理 NuGet 包

Search drawing and install package.搜图安装package。

Swear at Microsoft for making life hard.咒骂微软让生活变得艰难。

Done.完毕。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM