"Unable to load DLL" Error when Using Aspose.Slides for .NET in Docker Container

Hi,
I’m facing this issue running aspose in a windows container. I’m using ASpose.Slides.NET version 23.5.0

2023-09-01 09:39:20,853 ERROR SEPDFConverter.Service.ConverterService - Unable to load DLL 
'aspose.slides.drawing.capi_vc14x64' or one of its dependencies: The specified module could not be found. (0x8007007E)
System.DllNotFoundException: Unable to load DLL 'aspose.slides.drawing.capi_vc14x64' or one of     its dependencies: The spe
cified module could not be found. (0x8007007E)
   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, Nullable`1 s
earchPath, Boolean throwOnError)
   at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly,     Nullable`1 searchPath)
   at ♠♥▬♥☻.☻(String ☻, Assembly ♥, Nullable`1 ♣)
   at System.Runtime.InteropServices.NativeLibrary.LoadLibraryCallbackStub(String libraryName,     Assembly assembly, Boolea
n hasDllImportSearchPathFlags, UInt32 dllImportSearchPathFlags)
   at ♠♥▬♥☻.c(IntPtr& a)
   at System.Drawing.StringFormat.get_GenericTypographic()
   at ☼♣▬▬..ctor(Bitmap ☻)
   at ♫↨↑▬..ctor(Int32 ☻, Int32 ♥, Single ♣, Single, Boolean ♠, ☻☼▬▬ ♫, ♣↑→▬ ☼, List`1 ☻☻)
   at Aspose.Slides.Slide.☻(Boolean ☻, ♣↓♣☼ ♥, ☻☼▬▬ ♣, List`1, InterruptionToken ♠)
   at ♣↑↓▬.☻(Presentation ☻, Stream ♥, Int32[] ♣, PdfOptions, InterruptionToken ♠)
   at ♣↑↓▬.♥(Presentation ☻, Stream ♥, PdfOptions ♣, InterruptionToken)
   at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options               
   at Aspose.Slides.Presentation.Save(String fname, SaveFormat format, ISaveOptions options)

Here is my DockerFile

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app

EXPOSE 80
EXPOSE 443

COPY . ./

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["ConverterLib/ConverterLib.csproj", "ConverterLib/"]
COPY ["SEPDFConverter/SEPDFConverter.csproj", "SEPDFConverter/"]
RUN dotnet restore "ConverterLib/ConverterLib.csproj"
RUN dotnet restore "SEPDFConverter/SEPDFConverter.csproj"
COPY . .
WORKDIR "/src/SEPDFConverter"
RUN dotnet build "SEPDFConverter.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "SEPDFConverter.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SEPDFConverter.dll"]

@jean.heidemann,
Thank you for reporting on the issue.

Please share the following:

  • presentation file you used
  • code example that reproduces the exception

Hi @andrey.potapov, I tried to create a sample project but I’m having some problems, I can’t reproduce the problem because I’m facing with a GDI error and I don’t knopw why, my sample project is very similar to my official project.

System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.DllNotFoundException: Unable to load DLL 'gdiplus.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)

Here is my sample project: AsposeSlidesWindowsContainer.zip (21.1 KB)

Sample files: files.zip (93.4 KB)

As you can see, my project is configured to run on Linux, but I intend tu use the same project to run on windows too, and docker desktop created a Windows Image correcly even with the project configured for Linux.

I noticed my official project is showing the related DLLs as you can see here:

but in my sample project they didn’t appear
:

@jean.heidemann,
I am working on the issue and will get back to you as soon as possible.

Sorry @andrey.potapov, I tried too many things that I don’t remember very well.
The original error was correct, but using Aspose.Slides.NET version 23.5.0. Now I updated my official project to version 23.8.0 had the same problem as my sample project, the gdiplus.dll error. And I noticed that System.Drawing was deleted from Aspose Slides, right? Because this code doesn’t work anymore for thumbnail generation:

using (Presentation presentation = new Presentation(OriginalFilePath))
{
    using (Bitmap bitmap = presentation.Slides[0].GetThumbnail())
    {
        bitmap.Save(ThumbnailFilePath, ImageFormat.Jpeg);
    }
}

@jean.heidemann,

Could you please clarify what exactly happens when this code is executed?

This code isn’t executed, I’m getting error on imports

I have this alias in my .csproj file

This code was working on version 23.5.0 of Aspose Slides

@jean.heidemann,
Starting with version 23.6, there are some changes related to the System.Drawing.Common library. Please look at the following information:

Hi @andrey.potapov.

I updated my project with the libraries available as described in the release notes (but version 23.8) and I’m still facing the same problem.

Could you see my updated project here?

Here is the error

System.DllNotFoundException: Unable to load DLL 'aspose.slides.drawing.capi_vc14x64' or one of its dependencies: T
he specified module could not be found. (0x8007007E)
         at System.Runtime.InteropServices.NativeLibrary.LoadByName(String libraryName, QCallAssembly callingAssembly, B
oolean hasDllImportSearchPathFlag, UInt32 dllImportSearchPathFlag, Boolean throwOnError)
         at System.Runtime.InteropServices.NativeLibrary.LoadLibraryByName(String libraryName, Assembly assembly, Nullab
le`1 searchPath, Boolean throwOnError)
         at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly, Nullable`1 searchPa
th)
         at ♠↨▬▬.☻(String ☻, Assembly ♥, Nullable`1 ♣)
         at System.Runtime.InteropServices.NativeLibrary.LoadLibraryCallbackStub(String libraryName, Assembly assembly,
Boolean hasDllImportSearchPathFlags, UInt32 dllImportSearchPathFlags)
         at ♠↨▬▬.c(IntPtr& a)
         at System.Drawing.StringFormat.get_GenericTypographic()
         at ♥↨▬▬..ctor(Bitmap ☻)
         at ♠☻↓▬..ctor(Int32 ☻, Int32 ♥, Single ♣, Single, Boolean ♠, ☼↨▬▬ ♫, ♣♥▬☼ist`1 ☻☻)
         at Aspose.Slides.Slide.☻(Boolean ☻, ♣↓♣☼ ♥, ☼↨▬▬ ♣, List`1, InterruptionToken ♠)
         at ♣♥→▬.☻(Presentation ☻, Stream ♥, Int32[] ♣, PdfOptions, InterruptionToken ♠)
         at ♣♥→▬.♥(Presentation ☻, Stream ♥, PdfOptions ♣, InterruptionToken)
         at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
         at AsposeSlidesWindowsContainer.Controllers.PowerPointConverter.Convert(Stream file) in C:\src\Controllers\Powe
rPointConverter.cs:line 23
         at AsposeSlidesWindowsContainer.ConversionController.UploadFile(IFormFile file) in C:\src\ConversionController.
cs:line 24

@jean.heidemann,
Thank you for the sample project.

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-44189

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.

1 Like

@jean.heidemann,
Our developers have investigated the case and discovered that the files aspose.slides.drawing.capi_vc14x64.dll, aspose.slides.drawing.capi_vc14x86.dll and libaspose.slides.drawing.capi_x86_64_libstdcpp_libc2.23.so are not automatically copied to the net6.0 folder. To resolve this issue, please add the following script to your .csproj project file:

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="copy $(ProjectDir)Resources\DLL\*.* $(OutDir)" />
</Target>

Hi @andrey.potapov.
I added your code suggestion to my project and the files are in the docker image but the problem still persists



@jean.heidemann,
I am working on the issue and will get back to you soon.