简体   繁体   中英

Bitmap object not present in system.drawing?

I am new to C# and I am trying to create a bitmap object in C# in Visual Studio 2019, but it isn't working. I have .NET Framework updated to the latest version and I have resharper installed. I am using Windows 10.

Ive tried adding the references manually with Add/Reference... and it does not stay checked.
I added using system.drawing and using system.drawing.common to the top of my code.
I updated my .net core and enabled it in my project.

using System;
using System.Drawing.Common;

namespace Bot
{
    class Program
    {
        static void Main(string[] args)
        {
            var bmp = new Bitmap();
        }
    }
}

I expected it to create a bitmap object, but it won't compile and gives me errors saying that the bitmap object does not exist in system.drawing .

It looks like you don't have the package in your system/project. In you're project directory or from VScode terminal do this:

dotnet add package System.Drawing.Common --version 6.0.0

then add a reference to the package in you're project

Bitmap类是程序集System.Drawing.Common.dll一部分,因此您需要通过 Nuget 包安装System.Drawing.Common

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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