在.NET Core 2.2下的System.Drawing中找不到Image类 [英] Can't find Image class in System.Drawing under .NET Core 2.2

查看:54
本文介绍了在.NET Core 2.2下的System.Drawing中找不到Image类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据

添加来自 @KonradViltersten 的澄清评论:

<块引用>

传统上,System.Drawing 包含在完整的 .NET Framework 中,但不是 .NET Core,因为 System.Drawing 基于 Windows 绘图方法..NET 核心被设计为独立于平台,因此不包括任何特定于平台的内容(如绘图).由于如此要求此功能,MS 发布了一个单独的程序集,可以安装该程序集以提供该功能

According to the docs, there's supposed to be a class for thumbnail handling in the namespace System.Drawing. I want to create a model that has an image as a property and then save it to a database. However, when I try the code below, I get an error that the class isn't found in that namespace, regardless of the docs stating otherwise.

using System.Drawing;
public class Donkey
{
  public Image Image { get;set; }
}

What am I missing?!

I've googled it but only found old posts and examples that seem not to work.

解决方案

Try installing the System.Drawing.Common NuGet package. This contains Image and other related types like Bitmap.

PM> Install-Package System.Drawing.Common

You can also install using the NuGet Package Manager UI accessible by right-clicking the solution in Solution Explorer and choosing Manage NuGet Packages...

Adding a clarification comment from @KonradViltersten:

Traditionally, System.Drawing was included in the full .NET Framework, but not .NET Core because System.Drawing was based on Windows drawing methods. .NET core was designed to be platform independent and thus did not include anything that was platform specific (like drawing). Because this functionality is so requested, MS released a separate assembly that could be installed to provide the functionality

这篇关于在.NET Core 2.2下的System.Drawing中找不到Image类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆