在类库 (.NET Standard) 中找不到位图类

编程入门 行业动态 更新时间:2024-10-25 06:28:05
本文介绍了在类库 (.NET Standard) 中找不到位图类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想制作一个类库(.NET Standard),我正在使用 System.Drawing,

I want to make a Class Library (.NET Standard) and I'm using System.Drawing,

但我收到错误:

CS0246 C# 找不到类型或命名空间名称位图"(您是否缺少 using 指令或程序集引用?)

CS0246 C# The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)

我使用的是 .NET Standard 2.0.

I'm using .NET Standard 2.0.

推荐答案

更新

截至上个月(2018 年 5 月),Microsoft 发布了 System.Drawing.Common 的生产版本(以前是预览版/RC),这是一个取代 两个版本的 NuGet 包>CoreCompat.System.Drawing 包.这应该在以后使用.

As of last month (May 2018), Microsoft have a production release (previously it was preview/RC) of System.Drawing.Common, a NuGet package which supersedes both versions of the CoreCompat.System.Drawing package. This should be used going forwards.

对于那些使用 docker 的人

您还需要在最终 docker 映像中使用 libgdiplus 库,因为 System.Drawing.Common 依赖于此.您可以使用以下 Dockerfile 命令安装它:

You also need the libgdiplus library within your final docker image, as System.Drawing.Common relies on this. You can install that using the following Dockerfile command:

RUN apt-get update && apt-get install -y libgdiplus libc6-dev && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll && ln -s /usr/lib/x86_64-linux-gnu/libdl.so /lib64/libdl.so.2 && ln -s /usr/lib/x86_64-linux-gnu/libdl.so /lib64/libdl.so

旧答案

现在您可以使用 CoreCompat.System.Drawing nuget包.

For now you can use the CoreCompat.System.Drawing nuget package.

几个月来,我们一直在生产代码中使用它(在视频屏幕截图上绘制),并且效果很好.它基本上是 System.Drawing 的插入式替代品.

We've been using it in production code for a few months (drawing on video screencaps) and it has been working great. It's basically a slot-in replacement for System.Drawing.

更多推荐

在类库 (.NET Standard) 中找不到位图类

本文发布于:2023-11-17 05:50:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609052.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位图   中找   类库   Standard   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!