【发布时间】: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