Free Support Forum -

Aspose.Cells in AWS Lambda .NET Core 2.1 Function: Exception when saving to PDF

“errorType”: “CellsException”,
“errorMessage”: “The type initializer for '\u000f ’ threw an exception.”,
“stackTrace”: [
“at Aspose.Cells.Workbook.Save(Stream stream, SaveOptions saveOptions)”

How can I fix this?


Thanks for providing us details.

We did try this scenario for Aspose.Cells using Docker container assuming that “AWS Lambdas” is similar to docker container. We have tested this issue on Ubuntu 16.04 x64, in a docker container.
Here are our steps:

The docker we used was: microsoft/dotnet, install it first:
sudo docker pull microsoft/dotnet

Then, after running it straight away, we got the issue in this docker, We got the similar error upon saving to PDF.
We did the following things to sort it out:

We installed libgdiplus:

apt-get update
apt-get install -y libgdiplus
cd /usr/lib && ln -s gdiplus.dll
And install libc6-dev:
apt-get install -y --no-install-recommends libc6-dev

After doing all these steps, the issue passed away, and the PDF file was created successfully.
Would you please check it and share the feedback?


I managed to make it work by using lambda custom runtime (.net core 3) and lambda layer containing libgdiplus.x86_64 and glibc-devel.x86_64.

However now i encounter (sometimes) a different type of error:
“errorType”: “CellsException”,
“errorMessage”: “Shape to image Error!”,
“stackTrace”: [
“at Aspose.Cells.Workbook.Save(Stream stream, SaveOptions saveOptions)”

I cannot reproduce this on windows.

I use Aspose.Cells 19.9.0

Any idea how i can make this work?


Can you provide us sample code (runnable) and template file (if any) to reproduce the issue, we will check it soon. (149.1 KB)


I attached code and a file to reproduce the issue I mention.
I managed to reproduce it on AMI Linux.

I have already installed libgdiplus.x86_64 and glibc-devel.x86_64 on that Linux instance.
The zip I attached is light (has to be rebuilt and published)

Hope this helps. If there is any other info I can provide please let me know.

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNETCORE-34 – Exception "Shape to image Error!" while converting XLS to PDF


We evaluated your issue in details. We tested it on windows, MAC, linux, and found System.drawing.common does not support EMF on linux very well. Also saving EMF files will cause error on linux(Ubuntu 16.04 x64).
Sample code:

Image image0 = Image.FromFile("file.emf");
 image0.Save("file2.emf", System.Drawing.Imaging.ImageFormat.Emf);//on linux it fails

To make it more clear, we created a test project, please find it attached.

Probably we will skip EMF drawing on linux, to make sure the main file can be drawn properly, but some EMF elements will be missing until Microsoft fix this.

Thanks for your understanding! (533.6 KB)


As System.Drawing.Common do not support EMF on linux, We have skiped EMF drawing (rendering) on linux to make sure the main file could be drawn. But some EMF elements will be missing until Microsoft fixes this.

Please try using Aspose.Cells20.1.11 For .NetStandard20.
Aspose.Cells20.1.11 For .NetStandard20.Zip (4.1 MB)

Can you please your example with me? thanks!


Which example you are talking about? Please elaborate so we could provide you for your needs. Also, since you are not the owner of the thread, so you might not download the attachments in the thread. You may start a new thread in Aspose.Cells forum and ask for the example, we will share it with you in your thread.

Hi @catalinproteasa,

I am running into same issue:
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 LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output) at System.Drawing.SafeNativeMethods.Gdip…cctor() — End of inner exception stack trace —

I have created lambda runtime with .net core 3.1 and lambda layer containing libgdiplus.x86_64 and glibc-devel.x86_64 with custom runtime, still the same error.

Can you please share details and help me to solve the issue.

Thanks in advance.


See the thread for your reference which is helpful to use Aspose.Cells on AWS lambda environment,