I am having the same problem. Seems that Aspose.Cells is not working properly on a Docker image with Linux because the the libgdib is not installed or it is not linked to the proper version.
My code fails on AutoFitColumn always, but the issue is common because of the libgdib library.
System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception. —> System.EntryPointNotFoundException: Unable to find an entry point named ‘GdiplusStartup’ in DLL ‘libgdiplus’.
2019-01-06 17:30:03 at System.Runtime.InteropServices.FunctionWrapper`1.get_Delegate()
2019-01-06 17:30:03 at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
2019-01-06 17:30:03 at System.Drawing.SafeNativeMethods.Gdip…cctor()
2019-01-06 17:30:03 — End of inner exception stack trace —
2019-01-06 17:30:03 at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, HandleRef scan0, IntPtr& bitmap)
2019-01-06 17:30:03 at System.Drawing.Bitmap…ctor(Int32 width, Int32 height, PixelFormat format)
2019-01-06 17:30:03 at …ctor(Workbook )
2019-01-06 17:30:03 at …ctor(Workbook , String , String , Stream , HtmlSaveOptions )
2019-01-06 17:30:03 at …ctor(Workbook , String , String , HtmlSaveOptions )
2019-01-06 17:30:03 at Aspose.Cells.Workbook.Save(String fileName, SaveOptions saveOptions)
Are we having any updates on this or an ETA to fix it?
Yes, you are right as libgdiplus is required by Aspose.Cells while running on docker container. You may please follow the steps below as I have tried this scenario on Ubuntu 18.04.2 LTS (Bionic Beaver), in a docker container and it works fine.
Here are my steps:
The docker I use is: microsoft/dotnet, install it first:
sudo docker pull microsoft/dotnet
@zodraz,
Good to know that your issue is sorted out by the suggested script. Feel free to contact us at any time if you need further help or have some other issue or queries, we will be happy to assist you soon
Now I have the following error…Looks the same but it isn’t:
Take a look at the missing DLL: kernel32.dll.
The code crashes on the AutoFitRows method on a worksheet…
Of course I used your suggested approach…BTW could be related that .NET Core version is 3.0, and a s some forums suggest that is fixed on that version?
System.TypeInitializationException: The type initializer for ' ’ threw an exception. —> System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception. —> System.DllNotFoundException: Unable to load shared library ‘kernel32.dll’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libkernel32.dll: cannot open shared object file: No such file or directory
at Interop.Kernel32.LoadLibraryExW(String lpwLibFileName, IntPtr hFile, UInt32 dwFlags)
at System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary()
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 .(String , Font , Double )
at .(Cells , Int32 , Int32 , Int32 , Int32 , AutoFitterOptions )
at .(Cells , Int32 , Int32 , Int32 , Int32 , AutoFitterOptions )
@zodraz,
We have tried to reproduce this issue in Linux with .NET Core 3.1 but could not succeed. The sample workbook is loaded and AutoFitRows() executes successfully without any error. Could you please share your sample Excel file, runnable console application (simplified complete solution with minimum code) for our analysis? We will reproduce the scenario and provide assistance accordingly.
Here is a Docker file and test (Aspose.Cells version: 20.1.0)
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["TestAspose/TestAspose.csproj", "TestAspose/"]
RUN dotnet restore "TestAspose/TestAspose.csproj"
COPY . .
WORKDIR "/src/TestAspose"
RUN dotnet build "TestAspose.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "TestAspose.csproj" -c Release -o /app/publish
FROM base AS final
RUN apt-get update
RUN apt-get install -y libgdiplus
RUN cd /usr/lib && ln -s libgdiplus.so gdiplus.dll
RUN apt-get install -y --no-install-recommends libc6-dev
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TestAspose.dll"]
@zodraz,
We are still not able to observe the issue but we need to look into it more. We have logged the issue in our database for thorough investigation and for a fix(if applicable). Once, we will have some news for you, we will update you in this topic.
This issue has been logged as CELLSNETCORE-50 – Unable to find an entry point named ‘GdiplusStartup’ in DLL ‘libgdiplus’
@zodraz,
We are working on your issue related to System.DllNotFoundException: Unable to load shared library ‘kernel32.dll’. You have provided us two links:
I opened the link and it jumped to an “Azure container registry” page,
so I think maybe this is a problem in “Azure container”, not in “linux Docker container”?
Would you please confirm if is it true or not?
And, if it is really an Azure container, I think the reason is:
The sandbox that Azure Functions use is prohibited from accessing certain parts from the Windows API. In this case we are already investigating this issue reported in another thread and will link this ticket here when confirmed by you.
For this issue, we have done the following tests: (on Ubuntu 16.04)
1, Make a Dockerfile, and a .netcore3.1 project, put them in a folder named “Docker”(I will share all of them in the attachment).
2, In Ubuntu 16.04, run the following command: (I have made sure all the docker support is OK in my environment)
cd Docker
docker build -t testaspose:v1 .
The build of the Dockerfile is successful in my environment, resulting in “buildOK.png”.(in the attachment)
Please check if the crash you met, occurs in this build step?
3, In Ubuntu 16.04, run the following command:
docker run --rm -it testaspose:v1
And the test is OK, resulting in “runOK.png”.(in the attachment)
Please check if the crash you met, occurs in this run step?
Or please use the Docker folder in the attachment, to see if you can pass the test? Docker.zip (333.4 KB)
Hi @ahsaniqbalsidiqui,
I checked it and is working as expected.
The issue not working was trying to debugdirectly from VS2019 (on Windows) with Linux container those libgdiplus apparently seems to not being loaded (100% reproducible).
Working right now.
Thanks
@zodraz,
Good to know that your issue is sorted out by the suggested script. Feel free to contact us at any time if you need further help or have some other issue or queries, we will be happy to assist you soon.
Aspose.Cells now also provides separate .NET6.0 and .NET7.0 libraries (in the release archive) that use SkiaSharp as the graphics library, as recommended in official statement of Microsoft. For more details about using Aspose.Cells with NET6, please see the document on how to use and run Aspose.Cells for .NET6.0. The procedure would be the same to work on .NET7.0.
We also recommend to try using latest version/fix: Aspose.Cells for .NET (Releases | NuGet).