msgSystem.Drawing is not supported on this platform【netcore】

需求

netcore平台下,生成二维码~

过程

nuget包:

调用接口:

[Routing(EHttpMethod.HttpGet, "app/codes")]
        public CommonResult<string> CreteCodes(string id)
        {
            string strCode = "http://www.walys.com";
            QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator();
            QRCodeData qrCodeData = qrGenerator.CreateQrCode(strCode, QRCodeGenerator.ECCLevel.Q);
            QRCode qrcode = new QRCode(qrCodeData);

            // qrcode.GetGraphic 方法可参考最下发“补充说明”
            System.Drawing.Bitmap qrCodeImage = qrcode.GetGraphic(5, System.Drawing.Color.Black, System.Drawing.Color.White, null, 15, 6, false);
            qrCodeImage.Save(@"G:Users344343Desktop	est3.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            return "";
        }

  报错:

System.Drawing is not supported on this platform。

 问题分析

遇到这个问题,我就分析问题:

1.我的 System.Drawing 不支持netcore?这个不能啊,官方是不支持System.Drawing,但是我引用的是官方新类库:System.Drawing.Common

2.QRCoder,引用了netcore 不支持的System.Drawing====》这个网上一大堆使用netcore平台开发二维码的,都是使用的QRCoder开发的。

3.怀疑人生~~~~~~

 问题发现

第二天,发现新建一个netcore webapi项目,引用项目完全可以生成二维码。

 

这样就看publish包。发现除了好几个包。但是还有比较小的包。

发现项目中使用的就是小的包。

难道是这里有问题?为啥子是好几个版本的包呢?

后来手动把publish处理的dll拷贝到部署目录。调用接口~~~~妥妥的!!!

大家又遇到这种情况么?

原文地址:https://www.cnblogs.com/blogs2014/p/12174995.html