DllNotFoundException Is Thrown when Using Aspose.Slides on macOS with .NET 6

Powerpoint.zip (252.1 KB)
Unhandled exception. System.DllNotFoundException: Unable to load shared library ‘’ or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(lib, 0x0001): tried: ‘lib’ (no such file), ‘/System/Volumes/Preboot/Cryptexes/OSlib’ (no such file), ‘/usr/lib/lib’ (no such file, not in dyld cache), ‘lib’ (no such file), ‘/usr/local/lib/lib’ (no such file), ‘/usr/lib/lib’ (no such file, not in dyld cache)
at System.Runtime.InteropServices.NativeLibrary.LoadByName(String libraryName, QCallAssembly callingAssembly, Boolean hasDllImportSearchPathFlag, UInt32 dllImportSearchPathFlag, Boolean throwOnError)
at System.Runtime.InteropServices.NativeLibrary.LoadLibraryByName(String libraryName, Assembly assembly, Nullable1 searchPath, Boolean throwOnError) at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly, Nullable1 searchPath)
at .(String , Assembly , Nullable`1 )
at System.Runtime.InteropServices.NativeLibrary.LoadLibraryCallbackStub(String libraryName, Assembly assembly, Boolean hasDllImportSearchPathFlags, UInt32 dllImportSearchPathFlags)
at .a(Int32 a, Int32 b, Int32 c, IntPtr& d)
at .(Size , )
at .(Size )
at Aspose.Slides.Slide.GetThumbnail(Size imageSize)
at ( , IPresentation )
at (Presentation , Stream , , IPptxOptions, InterruptionToken )
at Aspose.Slides.Presentation.(Stream , , IPptxOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)
at <StartupCode$Powerpoint>.$Program.main@() in
Program.fs:line 13

Using

.net 6.0
Aspose.Slides.NET 23.4.0

Minimal example attached

I can try running on .net 5.0 target framework and making sure the libgdiplus is in one of the locations where it will look for it but then I get the following issue

Unhandled exception. System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception.
—> System.DllNotFoundException: Unable to load shared library ‘libgdiplus’ or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibgdiplus, 0x0001): tried: ‘liblibgdiplus’ (no such file), ‘/System/Volumes/Preboot/Cryptexes/OSliblibgdiplus’ (no such file), ‘/usr/lib/liblibgdiplus’ (no such file, not in dyld cache), ‘liblibgdiplus’ (no such file), ‘/usr/local/lib/liblibgdiplus’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’)), ‘/usr/lib/liblibgdiplus’ (no such file, not in dyld cache)
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
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, HandleRef scan0, IntPtr& bitmap)
at System.Drawing.Bitmap…ctor(Int32 width, Int32 height, PixelFormat format)
at(Size , )
at(Size )
at Aspose.Slides.Slide.GetThumbnail(Size imageSize)
at ( , IPresentation )
at (Presentation , Stream , PresentationTypeEx , IPptxOptions, InterruptionToken )
at Aspose.Slides.Presentation.(Stream , PresentationTypeEx , IPptxOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)
at <StartupCode$Powerpoint>.$Program.main@() in
Program.fs:line 13

After doing further investigation into this issue, I believe that this is probably part of the issue - https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only

The recommendations here suggest moving to a different drawing library that has cross platform support - it would be great to get an update on when this is likely to happen

@martinbryant

Aspose.Slides for .NET doesn’t support macOS .NET6 environments yet. We are going to add this feature in Aspose.Slides for .NET 23.5 or 23.6. SLIDESNET-43983 is a related task.

Aspose.Slides for .NET must work in macOS .NET5 environments. Please share in which way you install libgdiplus? It is possible to install libgdiplus with the “brew install mono-libgdiplus” command.

Hi @victor.krivolap thanks for replying

The 2nd stack trace I posted was using .net 5.0 and the install of libgdiplus was done using the same homebrew command that you mentioned

Note in the stack trace - ‘/usr/local/lib/liblibgdiplus’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’))

@martinbryant,

Please also share the macOS version and processor architecture you use.

I can’t reproduce the issue in macOS 12.6.5 x86_64. The error doesn’t appear.

I tried to reproduce the issue in macOS Ventura 13.1 arm64 and found that .NET5 is not supported anymore. It is possible to install it but it is not available in the installed dotnet list. Install .NET on macOS - .NET | Microsoft Learn

@martinbryant
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-43983

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you found earlier (filed as SLIDESNET-43983) have been fixed in Aspose.Slides for .NET 23.8 (ZIP, MSI).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.