如何在ASP.NET Core应用中使用位图资源? [英] How to use bitmap resources in ASP.NET Core app?

查看:115
本文介绍了如何在ASP.NET Core应用中使用位图资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 .netcore2.1 应用程序中使用几个位图资源,但是当我向项目中添加图像资源时,它会显示以下错误:

I'm trying to use a couple of bitmap resources within .netcore2.1 app but when I add an image resource to my project it shows the following error:

严重性代码描述项目文件行抑制状态错误资源'sign_here_tag'无法实例化.找不到System.Drawing.Bitmap,System.Drawing.Common,Version = 4.0.0.1,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51的类型.

Severity Code Description Project File Line Suppression State Error Resource 'sign_here_tag' could not be instantiated. Type System.Drawing.Bitmap, System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 cannot be located.

我的项目中安装了 system.drawing.common NuGet软件包,但错误仍然存​​在.

I have system.drawing.common NuGet package installed within my project, but the error's still coming up.

在安装CoreCompat.System.Drawing之后,我仍然出现此错误:

after installing CoreCompat.System.Drawing i still have this error coming up:

即使我将文件扩展名更改为wav(强制将其添加为MemoryStream),我仍然会收到错误消息:

Even if i change the file extension to wav(to force it to add it as a MemoryStream) i still get the error:

推荐答案

要在ASP.NET Core中使用名称空间 System.Drawing ,建议您安装此软件包:

To use namespace System.Drawing in ASP.NET Core, I suggest you to install this package:

CoreCompat.System.Drawing

Install-Package CoreCompat.System.Drawing -Version 1.0.0-beta006

Install-Package CoreCompat.System.Drawing -Version 1.0.0-beta006

(当然,请删除您在安装此软件包之前尝试过的所有参考文献)

安装后,您可以照常使用 System.Drawing.Bitmap System.Drawing.Image .

After installing, you can use System.Drawing.Bitmap and System.Drawing.Image as normally.

注意::如果要在类库中使用此程序包,请确保该库使用的是 .NET Standard

NOTE: If you want to use this package in class library, make sure the library is using .NET Standard

这篇关于如何在ASP.NET Core应用中使用位图资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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