AnKing
AnKing

Reputation: 2184

How to use bitmap resources in ASP.NET Core app?

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:

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.

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

after installing CoreCompat.System.Drawing i still have this error coming up: enter image description here

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

Upvotes: 5

Views: 6339

Answers (1)

Tân
Tân

Reputation: 1

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

(Of course, removing all reference(s) that you've tried before installing this package)

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

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

Upvotes: 4

Related Questions