报错:
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
标签:Int32,x1yun,System,生成,报错,Common,true,Drawing,图片 From: https://www.cnblogs.com/x1yun/p/18230714