You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET Core 6部署Ubuntu 20.04时libSkiaSharp加载失败求助

.NET Core 6部署Ubuntu 20.04后SkiaSharp无法加载libSkiaSharp共享库问题

开发的.NET Core 6应用在Windows 11本地运行正常,部署到Ubuntu 20.04服务器后,调用SkiaSharp时触发无法加载libSkiaSharp共享库的错误。已尝试以下方案均未解决:

  • 更换SkiaSharp.NativeAssets系列包
  • 调整发布目标运行时(Portable/linux-x64)
  • 手动移动库文件位置
  • 安装libfontconfig1
  • 检查库文件依赖与权限

错误信息

Linux环境调用SkiaSharp时触发如下错误:
[错误日志截图]

Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]:
System.TypeInitializationException: The type initializer for 'SkiaSharp.SKData' threw an exception. <e LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: fail: MyTest.Controllers.MyController[0] 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: The type initializer for 'SkiaSharp.SKData' threw an exception. 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: System.TypeInitializationException: The type initializer for 'SkiaSharp.SKData' threw an exception. 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: ---> 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 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: at SkiaSharp.SkiaApi.sk_data_new_empty() 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: at SkiaSharp.SKData..cctor() 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: --- End of inner exception stack trace --- 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: at SkiaSharp.SKData.Create(IntPtr address, Int32 length) 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: at SkiaSharp.SKBitmap.Decode(ReadOnlySpan`1 buffer) 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: at SkiaSharp.SKBitmap.Decode(Byte[] buffer) 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: at Test.Common.Image.ImageManager.GenerateImage(ImageOptions MyPost, Details details) in C:\Users\TestUser\source\repos\Test.Web.Main\Test.Common.Image\ImageManager.cs:line 109 
Feb 9 19:40:10 vmi1190349 dotnet-MyTest[9456]: at MyTest.Controllers.MyController.Get(ImageOptions MyPost) in C:\Users\TestUser\source\repos\Test.Web.Main\MyTest\Controllers\MyController.cs:line 84

补充细节

  • 项目通过SKTypeFace使用SkiaSharp处理文本,先后尝试SkiaSharp.NativeAssets.Linux与SkiaSharp.NativeAssets.Linux.NoDependencies包,均无效;未触发SKTypeFace相关代码时仍报错。
  • 已确认项目引用包([项目引用包截图])
  • 已检查libSkiaSharp.so文件权限([权限检查截图]),权限配置正常
  • 使用ldd命令验证库文件依赖,显示所有依赖均已存在([ldd依赖检查截图])
  • 已安装libfontconfig1包

内容的提问来源于stack exchange,提问作者Rudazzle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 10:17:23