QRCoder icon indicating copy to clipboard operation
QRCoder copied to clipboard

The type initializer for 'SkiaSharp.SKData' threw an exception.

Open SudhanshuAESS opened this issue 1 year ago • 0 comments

This is my code.

QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrData.Join("\n"), QRCodeGenerator.ECCLevel.Q); BitmapByteQRCode qrCode = new BitmapByteQRCode(qrCodeData);

byte[] qrCodeBytes = qrCode.GetGraphic(20); using (SKBitmap skBitmap = SKBitmap.Decode(qrCodeBytes)) {

 var directory = Path.Combine(Environment.CurrentDirectory, "Core/Uploads/Visitor/");
 if (!Directory.Exists(directory))
 {
     Directory.CreateDirectory(directory);
 }

 var path = Path.Combine(directory, $"{data.RequestNumber}.png");

 using (var fileStream = System.IO.File.OpenWrite(path))
 {
     skBitmap.Encode(SKEncodedImageFormat.Png, 100).SaveTo(fileStream);
 }

}

giving error : The type initializer for 'SkiaSharp.SKData' threw an exception.

After Deployment on Linux server.

Version: .Net6

SudhanshuAESS avatar Feb 22 '24 13:02 SudhanshuAESS