VSD to PNG on Linux - System.Drawing.Common is not supported on non-Windows platforms

Hi,
Using Aspose.Diagram on linux platform to convert Visio VSD to PNG doesn’t work and throws the following exception:

Unhandled exception. System.TypeInitializationException: The type initializer for '↓♣' 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.GdipStringFormatGetGenericTypographic(IntPtr& format)
   at System.Drawing.StringFormat.get_GenericTypographic()
   at ↓♣..cctor()
   --- End of inner exception stack trace ---
   at ↓♣..ctor()
   at ▬♣▬.☻(☻♣♣ ☻, ImageSaveOptions, Boolean ♣)
   at ▬♣▬.☻(☻♣♣ ☻, ImageSaveOptions, Stream ♣, Boolean ♠)
   at ▬♣▬.☻(☻♣♣ ☻, ImageSaveOptions, Stream ♣)
   at ▬♣▬.☻(Stream ☻, ImageSaveOptions, Diagram ♣)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   at d.♠(Object ☻)
   at d(Object ☻)
   at d(MethodBase ☻, Boolean)
   at d.♠↑(d ☻, ♣)
   at d.()
   at d.(Boolean ☻)
   at d.♠(Object ☻)
   at d(Object ☻)
   at d.♠()
   at d.♠☻→(d ☻, ♣)
   at d.()
   at d.(Boolean ☻)
   at d.♠(Object ☻)
   at d(Object ☻)
   at d.♠()
   at d.☻(Object ☻, UInt32)
   at d.(Boolean ☻)
   at d.(Boolean ☻)
   at d.☻(Object[] ☻, Type[], Type[] ♣, Object[] ♠)
   at d.☻(Int32 ☻, Type[], Type[] ♣, Boolean ♠)
   at d.♠→(d ☻, ♣)
   at d.()
   at d.(Boolean ☻)
   at d.♠(Object ☻)
   at d(Object ☻)
   at d.♠()
   at d.♠☻→(d ☻, ♣)
   at d.()
   at d.(Boolean ☻)
   at d.♠(Object ☻)
   at d(Object ☻)
   at d.♠()
   at d.☻(Object ☻, UInt32)
   at d.(Boolean ☻)
   at d.(Boolean ☻)
   at d.☻(Object[] ☻, Type[], Type[] ♣, Object[] ♠)
   at d.☻(Stream ☻, String, Object[] ♣, Type[] ♠, Type[] ♥, Object[] )
   at d.☻(Stream ☻, String, Object[] ♣)
   at d(Stream ☻, String, Object[] ♣)
   at Aspose.Diagram.Diagram.Save(String filename, SaveOptions options)
   at Program.<Main>$(String[] args) in /src/pg-aspose-linux/Program.cs:line 8

I could not find any mention of this limitation in the documentation.
I did see similar issues for Aspose.PDF and Aspose.Cells but the solutions mentioned there cannot be applied to Aspose.Diagram.

The use is pretty standard using the mcr.microsoft.com/dotnet/runtime:8.0 docker image with installed fonts.
I’m using the latest version (as of today) v24.2.0 of Aspose.Diagram nuget.

code:

using Aspose.Diagram;
using Aspose.Diagram.Saving;

var dir = args.Length > 0 ? args[0] : "/data";
var inPath = $"{dir}/in.vsd";
var outPath = $"{dir}/out.png";
var diagram = new Diagram(inPath);
diagram.Save(outPath, new ImageSaveOptions(SaveFileFormat.Png));

Please let me know if you need more details.

@mkresnicki
This occurs because from .Net 6 System.Drawing.Common is not supported on non-Windows platform (on Linux in particular).
We plan to support Aspose.Drawing as the default graphics engine instead of System.Drawing.Common in the first quarter of this year.
We are sorry for the inconvenience.

@philip.zhou
Many thanks for the fast response :slight_smile:
If you could provide a better estimate that would be very appreciated.

Is it realistic to expect it to be released by the end of March?

@mkresnicki
If everything goes smoothly, we will support this feature in version 24.4, which is set to be released in the first half of April this year.
Thanks.

I’ve tried the 24.4.0 and it works in my small reproduction project within linux container! :slight_smile:
Thank you

@mkresnicki
It is great that you were able to resolve this issue on your end. In case you have further inquiries or may need any help in future, please let us know by posting a new thread in Aspose.Diagram’ forum.
Thanks.