【问题标题】:Use System.Drawing.Bitmap from .NET Core 3.1 [duplicate]使用 .NET Core 3.1 中的 System.Drawing.Bitmap [重复]
【发布时间】:2020-09-09 23:54:24
【问题描述】:

我正在尝试使用 .NET Core 3.1 库中的 System.Drawing.Bitmap

根据文档https://docs.microsoft.com/en-us/dotnet/api/system.drawing.bitmap?view=dotnet-plat-ext-3.1,该类型在版本 3 中可用。

当我尝试使用 Bitmap 构建库时出现错误:

error CS1069: The type name 'Bitmap' could not be found in the namespace 'System.Drawing'.
This type has been forwarded to assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Consider adding a reference to that assembly

如何使用该类型创建 .NET Core 3 类库?

OBS:在 .NET Core WinForms 中使用该类型没有任何问题。 (并且不需要引用 nuget System.Drawing.Common,因为该类型已经在 SDK 中)。

【问题讨论】:

  • 那么唯一的方法是引用 NuGet 吗? @AlexeiLevenkov
  • @Lex Li stackoverflow.com/questions/54335778/… 这不是同一个问题,因为我使用的是 .NET Core 3.1,根据文档,我尝试使用的 System.Drawing.Bitmap 在 .NET Core 3.1 上可用`。但是没有用。仅当您必须使用 .NET Core 时才使用 NuGet 的 AFAIK
  • 1) 了解 Microsoft 文档的真正含义,blog.lextudio.com/… 2) 您尝试的完全错误,因为您需要的是包参考,而不是普通参考。

标签: c# .net-core system.drawing


【解决方案1】:

当尝试在 .NET Core 中处理图像时,我建议使用 ImageSharp,这是 NuGet 上一个非常易于使用的跨平台图像库。我很快就弄清楚了它是如何工作的,而且它的记录非常好。

【讨论】:

  • 谢谢你 VollRahm :-)。但这个想法是通过使用 SDK 中的东西来减少依赖的数量。
猜你喜欢
  • 2020-04-18
  • 2020-05-06
  • 1970-01-01
  • 1970-01-01
  • 2022-07-06
  • 2020-07-14
  • 1970-01-01
  • 2020-04-03
  • 1970-01-01
相关资源
最近更新 更多