My ASP.NET6 WebAPI containers crashed. after add reference DevExpress.XtraPrinting.PrintingSystemBase and Full Exception here
System.TypeInitializationException: The type initializer for 'DevExpress.XtraPrinting.PrintingSystemBase' threw an exception. ---> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See https://docs.devexpress.com/XtraReports/403589/ for more information. at DevExpress.XtraPrinting.PrintingSystemBase.AssertPlatformSupported() at DevExpress.XtraPrinting.PrintingSystemBase..cctor() --- End of inner exception stack trace --- at DevExpress.XtraPrinting.PrintingSystemBase.set_EngineKind(EngineKind value) at DevExpress.Printing.CrossPlatform.CustomEngineHelper.set_CustomEngineType(Type value) at DevExpress.Printing.CrossPlatform.CustomEngineHelper.RegisterCustomDrawingEngine(Type engineType) at ds.Invest.WebAPI.Helper.ServiceRegistor.AddReporting(IServiceCollection pServices) in /var/jenkins_home/workspace/INVEST_SERVICE/Web/ds.Invest.WebAPI/Helper/ServiceRegistor.cs:line 31 at ds.Invest.WebAPI.Startup.ConfigureServices(IServiceCollection services, IWebHostEnvironment env, IConfiguration config) in /var/jenkins_home/workspace/BNZ INVEST_SERVICE/Web/ds.Invest.WebAPI/Startup.cs:line 123 at ds.Invest.WebAPI.MainWeb.Main(String[] args) in /var/jenkins_home/workspace/BNZ INVEST_SERVICE/Web/ds.Invest.WebAPI/MainWeb.cs:line 45
Root Cause
- Breaking Change in .NET6 System.Drawing.Common only supported on Windows
Solution
- Workaround Solution: In webapi project file, add this section
<ItemGroup> <RuntimeHostConfigurationOption Include="System.Drawing.EnableUnixSupport" Value="true" /> </ItemGroup>
- Permanent Solution: use cross-platform library such as ImageSharp / SkiaSharp / Microsoft.Maui.Graphics
NOTE: Please check 3rd party library such as DevExpress is support cross-platform library or not.
Reference
- Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Learn
- Reporting .NET/.NET Core Limitations | Reporting | DevExpress Documentation
Discover more from naiwaen@DebuggingSoft
Subscribe to get the latest posts sent to your email.