I have a project using .Net Standard 2.0. And I am getting an error "Reference to type Bitmap claims it is defined in System.Drawing but it could not be found". Does .Net Standard 2.0 not support System.Drawing? Is there any alternative that I can use instead?
Asked
Active
Viewed 10 times
0
-
Did you add the System.Drawing.Common NuGet package? – ProgrammingLlama Nov 17 '22 at 10:40
-
"Does .Net Standard 2.0 not support System.Drawing?" - **no, it does not**, because `System.Drawing` is just a thin wrapper over GDI which is Win32-specific, whereas .NET Standard is cross-platform. – Dai Nov 17 '22 at 10:42
-
@Dai Can you please tell me what else to use to support Bitmap. – Jess Nov 17 '22 at 10:55
-
@ProgrammingLlama Yes System.Drawing.Common version 7.0 – Jess Nov 17 '22 at 10:56
-
What is your aim? Why are you targeting .NET Standard 2.0 if you want to write Windows-only code? (Even `System.Drawing.Common` [is Windows-only](https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only)) – Dai Nov 17 '22 at 10:56
-
@Dai I am comparing PDF's and it has images(Bitmap). So while doing this it throws this error. – Jess Nov 17 '22 at 10:59
-
...in then you should not be targeting .NET Standard 2.0 then. Why are you targeting it? – Dai Nov 17 '22 at 11:00
-
I am converting an existing .NetFramework project to .NetStandard so that I can refer it in a .NetCore application – Jess Nov 17 '22 at 11:07
-
Don't do that. It won't work. Besides, you can't use .NET Standard as a target for application projects. Just migrate directly to .NET Core 3.1 or later. – Dai Nov 17 '22 at 11:15