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

时间:2020-01-10 11:21:59   收藏:0   阅读:176

需求

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:\Users\344343\Desktop\test\3.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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!