If I run the net core 2.2. application from under Windows, everything works correctly. But when I run the application from under Docker on the Linux platform, I see an error
Exception thrown: ‘System.DllNotFoundException’ in SkiaSharp.dll
“The type initializer for ‘SkiaSharp.SKAbstractManagedStream’ threw an exception.”, “Level”: “ERROR”, “exception.message”: “The type initializer for ‘SkiaSharp.SKAbstractManagedStream’ threw an exception.”, "Exception.stacktrace “:” at SkiaSharp.SKAbstractManagedStream…ctor (Boolean owns) \ n at \ u000F. \ u0002 (Stream \ u0002) \ n at \ u000F …ctor (Stream \ u0002) \ n at Aspose.BarCode.Bitmap … ctor (Stream stream) \ n at Aspose.BarCode.BarCodeRecognition.BarCodeReader.SetBarCodeImage (Stream stream) \ n at Aspose.BarCode.BarCodeRecognition.BarCodeReader…ctor (Stream stream, BaseDecodeType type) \ n
I have created a simple console project for .NET Core and found it working fine in Windows and Ubuntu container in Docker. Then reference to Aspose.BarCode is added using NuGet package manager to the project and simple code for generating a sample barcode is added as given below:
// Instantiate barcode object and set differnt barcode properties
BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.Code128, "1234567");
generator.XDimension.Millimeters = 1f;
// Save the image to your system and set its image format to Jpeg
This project is tested in Windows and it works fine. However when same project is executed in Docker, above mentioned exception is observed as shared by you.
To resolve this issue I published the application using Visual Studio 2017 and executed the application from that published folder in Docker. It is observed that this time application executed successfully without any exception and barcode image was created. As during publishing, all the dependencies are resolved and made part of the published folder, you may please publish your application and execute application from this published folder. Please provide your feedback after publishing the application and testing in Docker.
Thank you for the feedback. When we publish the application, it contains all these dependencies. Good to know that you also found the solution and we will wait for your feedback once you test it in your environment.
It looks like Linux binary is not shipped with SkiaSharp. Therefore you have used the right approach to use the assembly at https://github.com/mono/SkiaSharp/releases .
If you download its NuGet package then it should be the latest version. Please put the downloaded SkiaSharp library in the same folder where loader can find it and it should work.
Hey. This file must be placed in the nuget folder of the SkiaSharp package. When updating SkiaSharp, you will have to download and place the file in a new package. If you work locally, it is tolerable, but if you collect a project on CI, sooner or later it helps to catch the bug. So far, unfortunately, I cannot offer another solution.
I would recommend adding this solution to the documentation. I think this question will arise for many clients.