Aspose.Cells Alpine Linux type initializer threw an exception

Hi team,

We are getting the following error when using Aspose.Cells from within Alpine Linux.

  Error Message:
     Aspose.Cells.CellsException : The type initializer for '\u0002   ' threw an exception.
  Stack Trace:
     at Aspose.Cells.Workbook.Save(Stream stream, SaveOptions saveOptions)
     at Aspose.Cells.Workbook.Save(Stream stream, SaveFormat saveFormat)

We are using alpine 3.11 with the following libraries installed:

icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib libgdiplus

and the .Net SDKs 3.1.411 and 5.0.302 installed (project targets 3.1)

We don’t have much to go on!! Is there any way of getting more information regarding the exception?

@jirish,

We recommend you to kindly try latest version, i.e., Aspose.Cells for .NET 21.7 (if you are not already using it). See and follow below instructions:

We did test this scenario on Ubuntu 16.04 x64, in a docker container.
Here are our steps:

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

Then, after running it,  we ran into similar issue in this docker, we got the error:

Aspose.Cells.CellsException : The type initializer for ‘???’ threw an exception.
at Aspose.Cells.Workbook.Save(String fileName, SaveOptions saveOptions)

In short, It seems to be the same error you also got.

To cope with it, we tried:
We installed libgdiplus:

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

And then installed libc6-dev:
`apt-get install -y --no-install-recommends libc6-dev`

After performing all these steps, the issue passed away, and the output file was created successfully.

See the following article for further reference:
How to Run Aspose.Cells in Docker

Hi @Amjad_Sahi,

I was aware of the article regarding Ubuntu setup. Ours for Alpine is very similar the only notable difference is that Alpine uses musl-libc and not libc6-dev.

Our Docker image looks like this:

FROM alpine:3.14
USER root
RUN apk --no-cache add bash sudo shadow
RUN apk --no-cache add curl
RUN apk --no-cache add icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib libgdiplus
USER app
ENV HOME=/app 
ENV DOTNET_ROOT=$HOME/.dotnet
ENV PATH="$PATH:$DOTNET_ROOT"
ENV PATH="$PATH:$DOTNET_ROOT/tools"
# install .NET SDK 3.1.411 (July 2021)
ENV DOTNET_SDK_VERSION=3.1.411
RUN wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-musl-x64.tar.gz \
    && dotnet_sha512='58bf68237e604cb4b5f64b71c140f5498ee4c2471689fc7630fdcf09c5694fe75d75961418fc4ac6cebac6544972aee98dc9c3cfab3876182c4a5eba694e90dc' \
    && echo "$dotnet_sha512  dotnet.tar.gz" | sha512sum -c - \
    && mkdir -p $DOTNET_ROOT \
    && tar zxf "dotnet.tar.gz" -C $DOTNET_ROOT \
    && rm dotnet.tar.gz

Then this container forms the basis of a build agent in which we build our .net solution successfully and run a large series of unit tests - however all of our Aspose tests fail with the above error.

We also had issues with libgdiplus missing initially but this was added to the container and resolved the problem but we are now receiving the error as I posted in my original message.

If you could ask the developers to investigate that would be great as it’s not clear where the problem lies.

Many thanks

@jirish,
We have analyzed this information and logged it in our database for further investigation. You will be notified here once any update is ready for sharing.

This issue is logged as:
CELLSNETCORE-130 - Exception raised while saving workbook in Alpine Linux

HI @jirish
We haven’t tried this before in Alpine because it’s so small that missing components are possible.
However, I am currently trying to investigate the issue.

I tried to run your Docker script directly in Ubuntu20.04 and threw the following exception:

ERROR: unable to select packages:
libgdiplus (no such package):
required by: world[libgdiplus]
The command ‘/bin/sh -c apk --no-cache add icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib libgdiplus’ returned a non-zero code: 1

If I remove “libgdiplus” from the Docker file, it throws an error in the last step:

unable to find user app: no matching entries in passwd file

So, can I run the docker script you provide run in Ubuntu?
I would appreciate it if you could provide some more detailed environment configuration steps.
such as : A folder, with a simple test program, and a Docker script that you can run directly.

Hi @jirish
Please try the following project, I made it on Alpine:
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base

I am using Microsoft’s Docker development and debugging solution, test passes in this environment:

Hi @jirish
Have you solved this issue? I found same issue with you but on Aspose.Html.Rendering. I’m using Aspose.Html v22.11.0. I also run it on Alpine Linux. This issue only happen on Alpine Linux, I tried in Debian Linux is fine.

@bayu.permana.tecno,

We did provide solution and sample to the user and hopefully it fixed his issue.

Please post your issue/queries in Aspose.HTML forum and one of our fellow colleagues from Aspose.HTML team will assist you soon.