Skip to content

[BUG] The type initializer for 'SkiaSharp.SKImageInfo' threw an exception in AWS .NET 6.0 #3235

Open
@MohanaselvamJ

Description

@MohanaselvamJ

Description

System.TypeInitializationException : The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.

Basic Information
• NuGet: SkiaSharp.NativeAssets.Linux.NoDependencies
• Version with issue: v3.116.1
• IDE: Visual Studio 2022
• Platform Target Frameworks: ASP.NET Core application with .NET 6.0
• Environment : AWS Elastic beanstalk

Additional Information
This issue not occur in .NET8.0 application

Replication steps:
Publish .NET 8.0 ASP.NET Core application in AWS Elastic beanstalk with given code

Code

int width = 800;
int height = 600;
string base64String;
 
//Create a new bitmap
using (var bitmap = new SKBitmap(width, height))
{
    // Create a canvas to draw on the bitmap
    using (var canvas = new SKCanvas(bitmap))
    {
        // Clear the canvas with a white color
        canvas.Clear(SKColors.White); 
 
        // Define the paint for drawing shapes
        var paint = new SKPaint
        {
            Color = SKColors.Blue,
            IsAntialias = true,
            Style = SKPaintStyle.Stroke,
            StrokeWidth = 5
        }; 
 
        // Draw a rectangle
        var rect = new SKRect(100, 100, 300, 300);
        canvas.DrawRect(rect, paint); 
 
        // Draw a circle
        paint.Color = SKColors.Red;
        canvas.DrawCircle(400, 400, 100, paint); 
 
        // Draw a line
        paint.Color = SKColors.Green;
        canvas.DrawLine(500, 100, 700, 300, paint); 
 
        // Save the bitmap to a file
        using (var image = SKImage.FromBitmap(bitmap))
        using (var data = image.Encode(SKEncodedImageFormat.Png, 100)) 
 
        using (var memoryStream = new MemoryStream())
        {
            data.SaveTo(memoryStream);
        }
    }
}

Expected Behavior

Should working fine

Actual Behavior

Exception

Version of SkiaSharp

3.116.0 (Current)

Last Known Good Version of SkiaSharp

2.88.9 (Previous)

IDE / Editor

Visual Studio (Windows)

Relevant Log Output

System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory at SkiaSharp.SkiaApi.sk_colortype_get_default_8888() at SkiaSharp.SKImageInfo..cctor() --- End of inner exception stack trace --- at SkiaSharp.SKBitmap..ctor(Int32 width, Int32 height, Boolean isOpaque) at Convert_Word_Document_to_PDF.Controllers.HomeController.SimpleSkiasharp() in

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions