Cannot find Bitmap Class in Class Library (.NET Standard)

六月ゝ 毕业季﹏ 提交于 2019-11-26 17:23:17

问题


I want to make a Class Library (.NET Standard) and I'm using System.Drawing, but I get the error:

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

I'm using .NET Standard 2.0.


回答1:


Update

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.


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

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.




回答2:


I'm the author of CoreCompat.System.Drawing. If you're on .NET Core 2.0, I'd recommend you'd move to System.Drawing.Common instead, which is the Microsoft-maintained implementation of System.Drawing for .NET Core.

If you're on Linux or macOS, make sure to install libgdiplus. On macOS, run brew install mono-libgdiplus; on Linux your package manager should provide you with a libgdiplus package.



来源:https://stackoverflow.com/questions/46722409/cannot-find-bitmap-class-in-class-library-net-standard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!