Aspose.Slides.NET6.CrossPlatform - The Type Initializer for '\u000E\u000F\u0019\u0005' Threw an Exception

Hi Aspose Support Team,

I am using alpine Linux (version 3.16) inside my docker container and I am usingAspose.Slides.NET6.CrossPlatform (version 24.3.0) to Convert PPT slide to image but I am getting the following error when I try to create Aspose.Slides.Presentation instance in my .NET 7 framework code:

The type initializer for ‘\u000E\u000F\u0019\u0005’ threw an exception.

Following is the full stack trace for the same:

at \u0002\u0005\u0005\u0005.\u0002(Presentation \u0002, Stream \b, InterruptionToken \u0005)\n
at Aspose.Slides.Presentation.\b(Stream \u0002, Boolean \b)\n
at Aspose.Slides.Presentation.\u0002(Stream \u0002, Boolean \b)\n
at Aspose.Slides.Presentation…ctor(Stream stream, LoadOptions loadOptions)\n
at Aspose.Slides.Presentation…ctor(Stream stream)\n

And Following is the docker file :

FROM alpine:3.16 AS base
WORKDIR /app
EXPOSE 80

RUN apk add --no-cache icu-libs
RUN apk add --no-cache libgdiplus

ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

ENV ASPNETCORE_URLS=http://*:80
RUN addgroup -g 2000 -S appuser && adduser -u 1000 -S appuser -G appuser -h /app
RUN chown appuser:appuser  /app /tmp
USER appuser:appuser

FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
ARG BUILD_CONFIGURATION=Debug
WORKDIR /src
COPY ["src/MyApp.Web/MyApp.Web.csproj", "src/MyApp.Web/"]
COPY ["src/MyApp.Application/MyApp.Application.csproj", "src/MyApp.Application/"]
COPY ["src/MyApp.Domain/MyApp.Domain.csproj", "src/MyApp.Domain/"]
COPY ["src/MyApp.Infrastructure/MyApp.Infrastructure.csproj", "src/MyApp.Infrastructure/"]
RUN dotnet restore "./src/MyApp.Web/MyApp.Web.csproj"
COPY . .
WORKDIR "/src/src/MyApp.Web"
RUN dotnet build "./MyApp.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./MyApp.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

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

We request your team to review the above configuration and provide your valuable input on this issue. Looking forward to getting a solution from Aspose Team.

@sujoshi,
Thank you for contacting support. I am working on the issue and will get back to you soon.

@sujoshi,
Thank you for your patience. Could you kindly also share the simplest project that reproduces the error you described?

Following is the code snippet where I am getting the error.

We are passing ppt as parameter and from there we are downloading the ppt document in bytes.
I am 100% sure that the pptUrl parameter gets a valid URL in request and we have tried with multiple URL’s and we are getting valid bytes. We have tried with reading bytes from a file stream also but the issue is the same while creating the instance of Aspose.Slides.Presentation object with memory stream.

[HttpGet("ppt/convert/image")]
public async Task<IActionResult> ConvertPptToImage(string pptUrl)
{
    try
    {
        using HttpClient client = new HttpClient();
        var getPptDocResult = await client.GetAsync(pptUrl);
        getPptDocResult.EnsureSuccessStatusCode();
        var docBytes = await getPptDocResult.Content.ReadAsByteArrayAsync();

        using MemoryStream memoryStream = new MemoryStream(docBytes);
        Aspose.Slides.Presentation presentation = new Aspose.Slides.Presentation(memoryStream);

        var thumbnail = presentation.Slides[0].GetThumbnail();

        using MemoryStream outputStrm = new MemoryStream();
        thumbnail.Save(outputStrm, System.Drawing.Imaging.ImageFormat.Jpeg);

        var response = new { ImageBytes = outputStrm.ToArray() };
        return Ok(response);
    }
    catch (Exception ex)
    {
        return BadRequest($"{ex.Message}:::{ex.StackTrace}");
    }
}

@sujoshi,
Thank you for the code example. Aspose.Slides for .NET 6 and .NET 7 requires GLIBC 2.23 or higher installed on the Linux Alpine. This can be the reason for the error you encountered.

Thank you for your suggestion @andrey.potapov
Could you please suggest some code snippet or any reference for installing GLIBC 2.23 or above in Alpine Linux, it will be of great help because last time when I tried installing GLIBC in alpine Linux it gets conflict with existing libraries.

Following is the error I get when installing GLIBC in alpine Linux:

ERROR: glibc-2.33-r0: trying to overwrite etc/nsswitch.conf owned by alpine-baselayout-data-3.2.0-r23

@sujoshi,
Unfortunately, the cross-platform version of Aspose.Slides for .NET 6 and .NET 7 does not work on Alpine at the moment. The issue arises because Alpine, by default, supports the musl libc library, while our product is built with glibc. These libraries are not compatible with each other.

Please note that the .NET Standard 2.1 version of Aspose.Slides works correctly on Alpine under .NET 7. However, this version requires the installation of the libgdiplus library.
Aspose.Slides for .NET 6 Cross Platform|Aspose.Slides Documentation

We plan to support legacy C++ standard libraries (glibs, musl) in the future.

@andrey.potapov
Thank you for the confirmation and for your assurance of your future plans for Apline Linux support.
I will try to use .netstandard2.1 library of Aspose.Slides. Can you confirm that I should install the library from NuGet package, or I have to download from Aspose website explicitly?

@andrey.potapov ,
Aspose.Slides library of .netstandard2.1 uses System.Drawing.Common which is not support in linux and we get the following error: System.Drawing.Common is not supported on this platform.
and Stack trace is :

at System.Drawing.Image…ctor()
at System.Drawing.Bitmap…ctor(Int32 width, Int32 height, PixelFormat format)
at e.(Size ,  )
at e.(Size )
at Aspose.Slides.Slide.GetThumbnail(Size imageSize)
at .( , IPresentation )
at .(Presentation , Stream , PresentationTypeEx , IPptxOptions , InterruptionToken )
at Aspose.Slides.Presentation.(Stream , PresentationTypeEx , IPptxOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format)

@sujoshi,

You can use the .NET Standard version of Aspose.Slides from both the NuGet and ZIP packages.

Could you kindly share the simplest project that reproduces the exception?

@andrey.potapov ,

Please find the sample project for the same on this link:
https://1drv.ms/u/s!AuBZtNunwqu5hMJbfHQeQgSn3ba4SA?e=ccNaie

I have used .netstandard2.1 library for aspose and getting the following error:

The type initializer for 'Gdip' threw an exception.
System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.

please refer the below screenshot in respective to the solution attached in above link:

image.png (118.5 KB)

@sujoshi,
Thank you for the sample project. I am working on the issue and will get back to you soon.

@sujoshi,
Thank you for your patience. I reproduced the error you are encountering.

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

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.