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
When you want to use asp.net core on .NET Full Framework only you can reference the old class libraries like this
{
"version": "1.0.0-*",
"frameworks": {
"net452": {
"dependencies": {
},
"frameworkAssemblies": {
"System.Drawing": "4.0.0.0",
}
}
}
}
Add NuGet reference Microsoft.Windows.Compatibility
Notice: mark "Include prerelease"
Of course, it works only if prerelease packages are OK for you.
I was able to replace System.Drawing with a multi-platform library called SkiaSharp. IF you're running on linux, you can also install this nuget so that you don't have to install the dependencies manually.
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/
System.Drawing
is not a good option with ASP.NET (more here: http://www.asprangers.com/post/2012/03/23/Why-you-should-not-use-SystemDrawing-from-ASPNET-applications.aspx)
If you want graphics manipulation i suggest to use ImageSharp (https://github.com/JimBobSquarePants/ImageSharp) on .Net Core or ImageProcessor (http://imageprocessor.org/) / ImageResizer (https://imageresizing.net/) on .Net Framework
Also, if you really need to use System.Drawing
change frameworks in your project.json to netstandard1.6
and add in dependencies "NETStandard.Library": "1.6.1"