Aspose.Total Runtime Gdip error on AWS Lambda

Deployed Aspose with dotnet 6.0 to AWS Lambda, we got following runtime error. The project has SkiaSharp.NativeAssets.Linux referenced. what else are we missing? Please help

Thanks
George

2023-01-06T22:30:31.488Z 036f6211-61b5-4f93-a1b4-af1a3e1c5f20 info [Error] SpanId:cb7249bce7da24de, TraceId:be3060d25f03eebc50f6f9413cd4405c, ParentId:0000000000000000 RequestPath:/pdf/htmlpdfgeneration RequestId:0HMNG6MEKV4VT PdfCompilationService.Controllers.PdfController.GenerateHtmlPDF (DocumentTransformation.API) => ATS.AspNetCore.Util.Mvc.CommonExceptionsFilter: The type initializer for ‘Gdip’ threw an exception. System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception.
—> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Learn for more information.
at System.Drawing.LibraryResolver.EnsureRegistered()
at System.Drawing.SafeNativeMethods.Gdip…cctor()
— End of inner exception stack trace —
at System.Drawing.SafeNativeMethods.Gdip.GdipCreateMatrix2(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy, IntPtr& matrix)
at System.Drawing.Drawing2D.Matrix…ctor(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy)
at #=z$Ul_8YJLKhX91dJuh5RQYNzUOceI3ICtLw==.#=z6Qnase$TK3JpuFwQqKuzdx8=(SizeF #=zk8jk1pg=)
at #=z$Ul_8YJLKhX91dJuh5RQYNzUOceI3ICtLw==.#=zs2DRKgY=(SizeF #=zk8jk1pg=)
at #=z34_2CmQkL8Lo4z8ozXkDoV3ak288XetwQw==.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=)
at #=z38PLXfUb9GFj6W8jA0WqwqmLWAAmAo8BDg==.#=zwRO_smmlXPZv(#=zdlfxE1uwcgy9dQJ7s__T$LY= #=zNAsL$oY6GIoderLGjA==, #=zotnWVGILg35dqJ2YkdvXHyaB1IKY[] #=zKKTie0sBbIA9, #=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, TimeSpan #=z1KolkUA=)
at #=zlhOACKlvO1qEu9mB7$w79_SxGMBt.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, TimeSpan #=z1KolkUA=, #=zb4LirBl5nVyFSUVH103NKlQ=[] #=zlEs7SI8=, #=ztd6TZKBhFSN6b7Lkank2N6g=[] #=zu8Uz03c=)
at #=zlhOACKlvO1qEu9mB7$w79_SxGMBt.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, TimeSpan #=z1KolkUA=, #=ztd6TZKBhFSN6b7Lkank2N6g=[] #=zu8Uz03c=)
at #=zH_G_28NYeIBGKU0yYBOgGOvXY3va.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, #=ztVLArws= #=zQ$qH$4U=, TimeSpan #=z1KolkUA=)
at #=zH_G_28NYeIBGKU0yYBOgGOvXY3va.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, #=ztVLArws= #=zQ$qH$4U=)
at #=z1yvGIJfkpswKgcKzMOiFOfUOfPjg.#=zLhn$3gJ8unPf(Stream #=zSV8quxjurIs7, Document #=zGCSiZAyeL7tI, HtmlLoadOptions #=z1OdzwGQGsM03, String #=z0ySSC29PmRbr)
at #=z1yvGIJfkpswKgcKzMOiFOfUOfPjg.#=z89X_cE4=(Stream #=zSV8quxjurIs7, Document #=zGCSiZAyeL7tI, HtmlLoadOptions #=z1OdzwGQGsM03, String #=z0ySSC29PmRbr)
at #=z1yvGIJfkpswKgcKzMOiFOfUOfPjg.#=z89X_cE4=(Stream #=zSV8quxjurIs7, Document #=zGCSiZAyeL7tI, HtmlLoadOptions #=z1OdzwGQGsM03)
at Aspose.Pdf.Document.#=ztooJgw0=(Stream #=z20NmJbA=, LoadOptions #=zbfHmrC8=)
at Aspose.Pdf.Document…ctor(Stream input, LoadOptions options)
at DocumentTransformation.Services.PdfService.GeneratePdf(Stream stream) in /vsts/agent/_work/5/s/DocumentTransformation.Logic/PdfService.cs:line 148
at PdfCompilationService.Controllers.PdfController.GenerateHtmlPDF(HtmlToPdfRequest request) in /vsts/agent/_work/5/s/DocumentTransformation.API/Controllers/PdfController.cs:line 94
at lambda_method7(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
— End of stack trace from previous location —
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2023-01-06T22:30:31.488Z 036f6211-61b5-4f93-a1b4-af1a3e1c5f20 info [Error] SpanId:cb7249bce7da24de, TraceId:be3060d25f03eebc50f6f9413cd4405c, ParentId:0000000000000000 RequestPath:/pdf/htmlpdfgeneration RequestId:0HMNG6MEKV4VT PdfCompilationService.Controllers.PdfController.GenerateHtmlPDF (DocumentTransformation.API) => ATS.AspNetCore.Util.Mvc.CommonExceptionsFilter: The type initializer for ‘Gdip’ threw an exception. System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception. —> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Learn for more information. at System.Drawing.LibraryResolver.EnsureRegistered() at System.Drawing.SafeNativeMethods.Gdip…cctor() — End of inner exception stack trace — at System.Drawing.SafeNativeMethods.Gdip.GdipCreateMatrix2(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy, IntPtr& matrix) at System.Drawing.Drawing2D.Matrix…ctor(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy) at #=z$Ul_8YJLKhX91dJuh5RQYNzUOceI3ICtLw==.#=z6Qnase$TK3JpuFwQqKuzdx8=(SizeF #=zk8jk1pg=) at #=z$Ul_8YJLKhX91dJuh5RQYNzUOceI3ICtLw==.#=zs2DRKgY=(SizeF #=zk8jk1pg=) at #=z34_2CmQkL8Lo4z8ozXkDoV3ak288XetwQw==.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=) at #=z38PLXfUb9GFj6W8jA0WqwqmLWAAmAo8BDg==.#=zwRO_smmlXPZv(#=zdlfxE1uwcgy9dQJ7s__T$LY= #=zNAsL$oY6GIoderLGjA==, #=zotnWVGILg35dqJ2YkdvXHyaB1IKY[] #=zKKTie0sBbIA9, #=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, TimeSpan #=z1KolkUA=) at #=zlhOACKlvO1qEu9mB7$w79_SxGMBt.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, TimeSpan #=z1KolkUA=, #=zb4LirBl5nVyFSUVH103NKlQ=[] #=zlEs7SI8=, #=ztd6TZKBhFSN6b7Lkank2N6g=[] #=zu8Uz03c=) at #=zlhOACKlvO1qEu9mB7$w79_SxGMBt.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, TimeSpan #=z1KolkUA=, #=ztd6TZKBhFSN6b7Lkank2N6g=[] #=zu8Uz03c=) at #=zH_G_28NYeIBGKU0yYBOgGOvXY3va.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, #=ztVLArws= #=zQ$qH$4U=, TimeSpan #=z1KolkUA=) at #=zH_G_28NYeIBGKU0yYBOgGOvXY3va.Render(#=zzbR$A7u$wUzl74ZRhiTFESYeM3B3 #=ze4Bn0wI=, #=ztVLArws= #=zQ$qH$4U=) at #=z1yvGIJfkpswKgcKzMOiFOfUOfPjg.#=zLhn$3gJ8unPf(Stream #=zSV8quxjurIs7, Document #=zGCSiZAyeL7tI, HtmlLoadOptions #=z1OdzwGQGsM03, String #=z0ySSC29PmRbr) at #=z1yvGIJfkpswKgcKzMOiFOfUOfPjg.#=z89X_cE4=(Stream #=zSV8quxjurIs7, Document #=zGCSiZAyeL7tI, HtmlLoadOptions #=z1OdzwGQGsM03, String #=z0ySSC29PmRbr) at #=z1yvGIJfkpswKgcKzMOiFOfUOfPjg.#=z89X_cE4=(Stream #=zSV8quxjurIs7, Document #=zGCSiZAyeL7tI, HtmlLoadOptions #=z1OdzwGQGsM03) at Aspose.Pdf.Document.#=ztooJgw0=(Stream #=z20NmJbA=, LoadOptions #=zbfHmrC8=) at Aspose.Pdf.Document…ctor(Stream input, LoadOptions options) at DocumentTransformation.Services.PdfService.GeneratePdf(Stream stream) in /vsts/agent/_work/5/s/DocumentTransformation.Logic/PdfService.cs:line 148 at PdfCompilationService.Controllers.PdfController.GenerateHtmlPDF(HtmlToPdfRequest request) in /vsts/agent/_work/5/s/DocumentTransformation.API/Controllers/PdfController.cs:line 94 at lambda_method7(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() — End of stack trace from previous location — at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

@gjin2023

The issue may be occurring due to the Aspose.PDF for .NET having dependency of System.Drawing. We are in process of replacing this dependency entirely with a new component. Some beta functionality was incorporated in 22.11 and 22.12 versions of the API. Would you please share which API version are you using?

we are currently using 22.06

@gjin2023

Aspose.PDF.Drawing NuGet package was released, DLL in this package doesn’t have System.Drawing.Common dependency.

You only need to install Aspose.PDF.Drawing instead of Aspose.PDF. Aspsoe.PDF with Drawing contains Aspose.Drawing inside, installing neither System.Drawing nor Aspose.Drawing is required.

This assembly correctly works under Linux environment. It will be published as separated assembly until we sure that this works absolutely perfect and may replace current System.Drawing-based assembly by 100%. When we ensure that, we will replace System.Drawing version with Aspose.Drawing one.