.net core 根据网络地址或者本地文件地址生成图片文件 本地测试没问题 发布到iis上之后 提示System.Drawing is not supported on this platform.

private System.Drawing.Image GetImage(string path)
        {
            try
            {
                if (path.StartsWith("http"))
                {
                    System.Net.WebRequest request = System.Net.WebRequest.Create(path);
                    request.Timeout = 10000;
                    System.Net.HttpWebResponse httpresponse = (System.Net.HttpWebResponse)request.GetResponse();
                    Stream s = httpresponse.GetResponseStream();
                    return System.Drawing.Image.FromStream(s);
                }
                else
                {
                    return System.Drawing.Image.FromFile(path);
                }
            }
            catch (Exception)
            {
                return null;
            }

        }

图片说明
这是错误 我仔细排查 把出问题的代码锁定在这个方法里 求教 这段为什么在iis上面出现了问题 是需要安装什么东西吗

,net core不支持System.Drawing,这个道理不难理解,因为System.Drawing 基于windows的gdi/gdi+库,根本没法移植,被.net core抛弃了。

可以用mono版本的代替:https://github.com/mono/mono/tree/master/mcs/class/System.Drawing

可能是发布的程序中【System.Drawing.Common.dll】这个文件有问题

我的程序时基于.net core 2.2,发布时【System.Drawing.Common.dll】的大小为141KB,

在publish\runtimes\win\lib\netcoreapp2.0目录下有一个大小为659KB的,这个才是正常的。

将该dll拷贝替换网站目录下的同名文件即可解决。