FastReports / FastReport

Free Open Source Reporting tool for .NET6/.NET Core/.NET Framework that helps your application generate document-like reports

Home Page:https://www.fast-report.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"System.Drawing.Common is not supported on non-Windows platforms" exception on MacOS environments

victorvilella opened this issue · comments

Describe the bug
I'm using a dotnet core 6.0 application that I'll run mostly on Windows and Linux environments. Recently I got an MacBook Pro and I tried to run my app on this computer and I received this exception System.Drawing.Common is not supported on non-Windows platforms at running app.UseFastReport(); onProgram.cs.

To Reproduce
Steps to reproduce the behavior:

  • Create a new dotnet core application in a Mac OS environment
  • Install FastReport.Opensource and some related libs to render it's reports
  • Add app.UseFastReport(); on Program.cs
  • Run the app

Expected behavior
This app must run without problems and exceptions.

Stacktrace

System.TypeInitializationException: The type initializer for 'FastReport.Utils.Config' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'FastReport.TypeConverters.FontConverter' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
 ---> 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.GdipNewPrivateFontCollection(IntPtr& fontCollection)
   at System.Drawing.Text.PrivateFontCollection..ctor()
   at FastReport.TypeConverters.FontConverter..cctor()
   --- End of inner exception stack trace ---
   at FastReport.TypeConverters.FontConverter.get_PrivateFontCollection()
   at FastReport.Utils.FRPrivateFontCollection..ctor()
   at FastReport.Utils.Config..cctor()
   --- End of inner exception stack trace ---
   at FastReport.Utils.Config.set_WebMode(Boolean value)
   at Microsoft.AspNetCore.Builder.FastReportBuilderExtensions.UseFastReport(IApplicationBuilder app, Action`1 setupAction)
   at Program.<Main>$(String[] args) in /my/program/Program.cs:line 64

Device (please complete the following information):

  • OS: MacOs Monterey (12.6)
  • Browser: Any Browser (app crashes before start its web server)

Thanks in advance.

commented

Try to set System.Drawing.EnableUnixSupport = true in the runtimeconfig.json file
https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only

Hello, @victorvilella !
FastReport.Opensource does not support development for macOS. System.Drawing.Common, starting with version 7.0, will completely stop supporting non-Windows systems, so the examples of libgdiplus given above will soon not work at all.
Only the commercial version of FastReport.Core.Skia has support.
See here:
https://www.fast-report.com/en/blog/show/fastreport-core-skia/