Description
Description
Issue:
System.TypeInitializationException : The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
Replication steps:
- Create .NET Framework 4.8 console app.
- Run the code
Note:
This issue not occur in previous Skiasharp version 2.88.8. It seems like breaking issue
Code
//Define the image dimensions
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
Works properly
Actual Behavior
Unhandled Exception: System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception. ---> System.DllNotFoundException: Unable to load library 'libSkiaSharp'.
at SkiaSharp.LibraryLoader.LoadLocalLibrary[T](String libraryName) in //binding/Binding.Shared/LibraryLoader.cs:line 40
at SkiaSharp.SkiaApi.<>c.<.cctor>b__1741_0() in //binding/SkiaSharp/SkiaApi.cs:line 17
at System.Lazy1.CreateValue() at System.Lazy
1.LazyInitValue()
at System.Lazy`1.get_Value()
at SkiaSharp.SkiaApi.sk_colortype_get_default_8888() in //binding/SkiaSharp/SkiaApi.generated.cs:line 6052
at SkiaSharp.SKImageInfo..cctor() in //binding/SkiaSharp/SKImageInfo.cs:line 48
--- End of inner exception stack trace ---
at SkiaSharp.SKBitmap..ctor(Int32 width, Int32 height, Boolean isOpaque) in /_/binding/SkiaSharp/SKBitmap.cs:line 33
Version of SkiaSharp
3.116.1
Last Known Good Version of SkiaSharp
2.88.8 (Deprecated)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Windows
Platform / Operating System Version
No response
Devices
No response
Relevant Screenshots
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Type
Projects
Status