5

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

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

9 Comments

I got the same result using this package, i've updated the question to show the error
@AnKing Have you tried to remove reference System.Drawing.Common? You should try again with my suggestion: removing all reference(s) that you've tried before installing this package
In my solution explorer I only have reference to SDK (Microsoft.NETCore.App(2.1)) which contains System.Drawing.dll But I'm not sure how to remove this reference without removing the entire sdk. is there a trick to it?
@AnKing You can create new project (for testing) and install this package. Code, build and run. If it works, the problem may come from another place.
I just created a new project and was able to add resource without any problems. It goes right into "images" section of the resources. So there must be in issue with visual studio not finding system.drawing.bitmap for that particular project for some reason
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.