mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.41k stars 535 forks source link

[QUESTION] Implement SkiaSharp on Azure Function V3 without publishing. #2053

Open brandonvqz opened 2 years ago

brandonvqz commented 2 years ago

I'm currently developing a Azure funtion that generates a PDF file using QuestPDF and SkiaSharp. But whenever I try to execute the function without any assembly reference error I still get this issue:

SkiaSharp.SKAbstractManagedWStream' threw an exception at SkiaSharp.SKAbstractManagedWStream..ctor(Boolean owns) at SkiaSharp.SKDocument.CreatePdf(Stream stream, SKDocumentPdfMetadata metadata) at QuestPDF.Drawing.DocumentGenerator.GeneratePdf(Stream stream, IDocument document) at QuestPDF.Fluent.GenerateExtensions.GeneratePdf(IDocument document, Stream stream)

I wonder, is there any way to implement SkiaSharp with QuestPDF on a Azure Function V3 on netcore3.1 without using the publish function from VS?

I used the .proj file on the function with no positive result. When I try to execute the same code on Visual Studio it does work with no problem at all.

I don't get any assembly issues but I do get that exception.

Any help is appreciated, thanks!!

[EDIT]: In case that any code is needed I can share some of it!

mattleibow commented 2 years ago

Is this related to #1001?

I need to check the status of native things in azure functions again. Have you tried newer runtimes like net6? I am wondering if the SDK has made improvements.

brandonvqz commented 2 years ago

Is this related to #1001?

I need to check the status of native things in azure functions again. Have you tried newer runtimes like net6? I am wondering if the SDK has made improvements.

It is somekind related to #1001 but all the solutions given where mentioning the .csproj or .proj file, none of them work without using the Publish feature from Visual Studio.

But this error comes directly from the library itself. What I mean is, the error given by the function is not because the library couldn't find libSkiaSharp.dll, I assume it's because System.Memory.dll is not updated.

And no, I haven't tried on NET6, I'll try it and I'll keep you updated.

NOTE: When importing the reference from both SkiaSharp and QuestPDF the function start to log many outdated references or a lot of "obsolete" references.