Unable to find an entry point named ‘GdiplusStartup’ in DLL ‘libgdiplus’

Hi,
Related to this issue on Aspose.Cells

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?

Thanks

@zodraz,

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:

  1. The docker I use is: microsoft/dotnet, install it first:
    sudo docker pull microsoft/dotnet

  2. Then I install libgdiplus:

apt-get update
apt-get install -y libgdiplus
cd /usr/lib && ln -s libgdiplus.so gdiplus.dll

  1. And install libc6-dev:

apt-get install -y --no-install-recommends libc6-dev

So many thanks @ahsaniqbalsidiqui,

It actually worked and saved me the day.

Cheers

@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

Hi @ahsaniqbalsidiqui,

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 )

Thanks

@zodraz,
We are working on this issue and will share our feedback as soon as the environment is established and issue is reproduced.

@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.

Hi,

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"]

using Aspose.Cells;
using System;

namespace TestAspose
{
class Program
{
static void Main(string[] args)
{
Workbook newWorkbook = new Workbook();
Worksheet worksheet = newWorkbook.Worksheets.Add(“New Sheet”);
Cells cells = worksheet.Cells;
cells[0, 0].PutValue(“Some Text”);
worksheet.AutoFitRows();
newWorkbook.Save(“kkkkkkk”);
Console.WriteLine(“Hello World!”);
}
}
}

Not even changing to bionic (Ubuntu) image works.

Cheers

@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:

mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim
mcr.microsoft.com/dotnet/core/sdk:3.1-buster

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.

Hi,

I do not understand what you are talking about…Just take these steps to reproduce the issue:

1-On a windows machine create a VS2019 project and add the code I provided on a prior post…It looks like:

static void Main(string[] args)
{
Workbook newWorkbook = new Workbook();

2-Add support for Docker in Linux(which will give the code I provided on a previous post.) It looks like this:

FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
WORKDIR /app
....

2.1-Verify that this code has the libgdiplus (it is already on my code for the Docker container)

3-Execute (and debug) via Docker Linux.

4-Verify it crashes.

Thanks

@zodraz,
Thank you for sharing the information. We are analyzing it and will share our feedback soon.

@zodraz,

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 debug directly 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.

@zodraz,

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).