dotnet 修复在 Linux 上使用 SkiaSharp 提示找不到 libSkiaSharp 库

我的应用在 Windows 上跑的好好的,放在 Linux 上一运行就炸掉了,异常内容如下 Unhandled exception. System.TypeInitializationException: The type initializer for'SkiaSharp.SKColorSpa...

我的应用在 Windows 上跑的好好的,放在 Linux 上一运行就炸掉了,异常内容如下

Unhandled exception. System.TypeInitializationException: The type initializer for'SkiaSharp.SKColorSpace' threw an exception.---> System.DllNotFoundException: 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 at SkiaSharp.SkiaApi.sk_colorspace_new_srgb() at SkiaSharp.SKColorSpace..cctor()--- End of inner exception stack trace --- at SkiaSharp.SKColorSpace.CreateSrgb() at Program.<Main>$(String[] args)ind:\lindexi\Code\SkiaSharp\SkiaSharp\KebeninegeeWaljelluhi\KebeninegeeWaljelluhi\Program.cs:line 5

原因是 Linux 的版本众多,大家都很喜欢自己定义,这让 SkiaSharp 不知道包含哪个版本才是能让大家都开心的,如官方文档 所讲的故事

解决的方法是再安装上 SkiaSharp.NativeAssets.Linux 或 SkiaSharp.NativeAssets.Linux.NoDependencies 库即可

如在 csproj 上添加以下代码用来安装

<ItemGroup><PackageReference Include="SkiaSharp" Version="2.88.0"/><PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.0"/></ItemGroup>




  • 发表于 2023-12-08 12:43
  • 阅读 ( 948 )
  • 分类:安装使用

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
admin
admin

DTcms技术经理

2 篇文章

作家榜 »

  1. dtcms 11 文章
  2. 轻风 2 文章
  3. admin 2 文章
  4. <script>alert("hello")</script> 1 文章
  5. alinly 1 文章
  6. bear 1 文章
  7. 不思进取的.NET开发 1 文章
  8. 枫叶飘 1 文章