Type initializer for 'SkiaSharp.SKTypeface' threw an exception.

I am encountering this error while deploying FlexCel as a lambda function in AWS. Here is the .csproj file for better context:

I am not able to figure why this is happening since it is working fine locally, can you guide me on how to fix this issue?

PS: I have tried with SkiaSharp.NativeAssets.Linux but threw the same error so tried with SkiaSharp.NativeAssets.Linux.NoDependencies hoping it would resolve the issue but didn't.

I sadly don't have much experience in lambdas and AWS, but could it be that you don't have fonts in your server? Given that the error is trying to initialize SKTypeface, my guess would be there aren't fonts to retrieve. Here is an article on how to install ms fonts in ubuntu: How to Install Microsoft Fonts on Ubuntu Linux [Easy Way]
MAybe it can be adapted for aws?

Also make sure you have fontconfig in the server. See Running FlexCel inside Docker containers | FlexCel Studio for the .NET Framework documentation for how to install fontconfig in most common linux distros

Heyy I tried both of these solutions, It didn't work. I will try running it in docker and then deploying it. Until then if you have any other solution please do let me know. Here is more detailed error message:

The type initializer for 'SkiaSharp.SKTypeface' threw an exception. | Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory

Thank you :)

Searching for this leads to this rabbit hole: Unable to load shared library 'libSkiaSharp' or one of its dependencies - azure app service on Linux · Issue #1341 · mono/SkiaSharp · GitHub
There are some solutions proposed here, can you try them?

I tried all the solutions proposed here. None of them seem to work. Before deploying FlexCel 7.23 I tried deploying 7.22-trial version in aws just to see if it works there. I had the same problem but it got resolved by one of solutions proposed here. This doesn't seem to work for FlexCel 7.23 because it depends on SkiaSharp 3.116 or higher and the solutions proposed here is for 2.88. I am now going to deploy in azure function which runs on windows.

Yes, we had to increase the minimum supported SkiaSharp due to vulnerabilities in 2.88 (see for example Vulnerable package SkiaSharp 2.88.0 is used. )

But that was the only reason we raised the requirement, FlexCel 7.23 should still work with 2.88 if you want (of course, please don't use 2.88.0 or any other vulnerable version, but 2.88.9 should work). You would need to recompile FlexCel dll requiring 2.88.9, but it is doable.

I can't sadly help much more here, since this is a skia sharp issue, they should fix it. There is not much we can do here

Got it.

Thank you so much :)