随笔 - 21  文章 - 0  评论 - 0  阅读 - 3294

.netCore System.Drawing.Common 发布,在CentOS 运行报错,生成图片流时。会因为不支持在liunx平台生成图片。

报错:

System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.

 

> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.
   at System.Drawing.LibraryResolver.EnsureRegistered()
   at System.Drawing.SafeNativeMethods.Gdip.PlatformInitialize()
   at System.Drawing.SafeNativeMethods.Gdip..cctor()
   --- End of inner exception stack trace ---
   at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, IntPtr scan0, IntPtr& bitmap)
   at QRCoder.QRCode.GetGraphic(Int32 pixelsPerModule, Color darkColor, Color lightColor, Boolean drawQuietZones)
   at QRCoder.QRCode.GetGraphic(Int32 pixelsPerModule)
   at x1yun.xyUnity.Exchanger.GerQrCodeStream(String paystr, Int32 pixels) in D:\x1yun\x1yunAPI\xyUnity\Exchanger.cs:line 1026
   at x1yun.xyForeign.SenparcWx.WxpaymentSdk.getWxNativePayAsync(sev_order_record ordRecod) in D:\x1yun\x1yunAPI\xyForeign\SenparcWx\WxpaymentSdk.cs:line 92

 

解决:

构建项目时,会在输出目录中生成[appname].runtimeconfig.json文件,只需要修改该配置文件即可

例如 生成的 Test.Api.runtimeconfig.json 文件

{
  "runtimeOptions": {
    "tfm": "net6.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "6.0.0"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "6.0.0"
      }
    ],
    "configProperties": {
      "System.GC.Server": true,
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Reflection.NullabilityInfoContext.IsSupported": true,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
      "System.Drawing.EnableUnixSupport": true 
    }
  }
}

没有的话加上, "System.Drawing.EnableUnixSupport": true 

 

posted on   侗家小蚁哥  阅读(71)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示