.NET Core 和 System.Drawing [英] .NET Core and System.Drawing
问题描述
我试图在面向 net46 的 .net 核心控制台应用程序中引用 System.Drawing,但程序集不存在.根据 MS 如果您使用 dotnetcore System.Drawing 不可用.但是如果你引用完整的 .net 框架,你应该可以使用它
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
这是我的 project.json
This is my project.json
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
},
"frameworks": {
"net46": {
}
}
}
不知道是什么问题
推荐答案
System.Drawing
不是 ASP.NET 的好选择(更多信息请访问:http://www.asprangers.com/post/2012/03/23/Why-you-should-not-use-SystemDrawing-from-ASPNET-applications.aspx)
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)
如果你想要图形操作,我建议使用 ImageSharp (https://github.com/JimBobSquarePants/ImageSharp) 在 .Net Core 或 ImageProcessor (http://imageprocessor.org/)/ImageResizer (https://imageresizing.net/) on .Net Framework
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
另外,如果你真的需要使用 System.Drawing
将 project.json 中的框架更改为 netstandard1.6
并添加依赖项 "NETStandard.Library": "1.6.1"
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"
这篇关于.NET Core 和 System.Drawing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!