I am trying to reference System.Drawing in a .net core console app targeting net46 but the assembly is not there. According to MS if you use dotnetcore System.Drawing is not available. But if you reference full .net framework you should be able to use it
This is my project.json
{ "version": "1.0.0-*", "buildOptions": { "emitEntryPoint": true }, "dependencies": { }, "frameworks": { "net46": { } } }
Any idea what is the problem
The Graphics class provides methods for drawing to the display device. Classes such as Rectangle and Point encapsulate GDI+ primitives. The Pen class is used to draw lines and curves, while classes derived from the abstract class Brush are used to fill the interiors of shapes.
Drawing. Common is used cross-platform mostly for image manipulation, such as QR code generators and text rendering. We haven't noticed heavy graphics usage, as our cross-platform graphics support is incomplete. The usages we see of System.
NET Core Runtime is cross-platform and can run on Mac and Linux, when using desktop frameworks with . NET Core, your app still relies on the underlying Windows platform. WinForms uses the WindowsAPI and Hwnd style-rendering and WPF uses DirectX; both of those platforms are directly tied to the native Windows OS.
Net Framework assembly into a Core or Standard project, it will compile but with the dreaded “This package may not be fully compatible with your project” warning. You can only verify the availability of all the types by running the project, so you can only guarantee compatibility through run-time testing.
I know this is old, but there is now a port of the library called System.Drawing.Common
. Try installing that one with NuGet.
To make this possible, there is a metapackage called Windows Compatibility Pack
. However, this metapackage includes many, many Windows related APIs (distributed as packages).
Source: https://developers.de/2018/01/22/how-to-use-system-drawing-in-net-core/
Add NuGet reference Microsoft.Windows.Compatibility
Notice: mark "Include prerelease"
Of course, it works only if prerelease packages are OK for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With