将 libgdiplus 与 IronOCR 结合使用:设置指南
This article was translated from English: Does it need improvement?
TranslatedView the article in English
.NET Core 需要libgdiplus来使用 Microsoft System.Drawing.Common NuGet 包。 如果在 macOS 或 Linux 系统上找不到该组件,您可能会遇到以下异常:
- 未处理的异常。 System.DllNotFoundException:无法找到或加载任何名称的本机库:[ libgdiplus, libgdiplus.so ]_ 如果您看到
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception,请阅读我们的.NET 6 版 System.Drawing.Common指南。
Linux
Ubuntu、Debian
要在 Ubuntu 或 Debian 上安装所需的库,请运行以下命令:
# Update package lists and install necessary libraries
sudo apt-get update && sudo apt-get install -y apt-utils libgdiplus libc6-dev# Update package lists and install necessary libraries
sudo apt-get update && sudo apt-get install -y apt-utils libgdiplus libc6-devSHELL
Docker
在您的 Dockerfile 中添加以下行,以确保必要的库包含在您的 Docker 镜像中:
# Update package lists and install necessary libraries in Docker container
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-devmacOS
如果您在 macOS 上遇到以下异常:
未处理的异常。 System.DllNotFoundException:无法找到或加载任何名称的本机库:[ libgdiplus, libgdiplus.dylib ]_
您可以通过以下方式解决此问题:
- 将runtime.osx.10.10-x64.CoreCompat.System.Drawing NuGet 包添加到您的 .NET 解决方案中,以便在您的项目中包含libgdiplus 。 或者,您也可以使用以下命令通过 Homebrew 手动安装该库:
# Update Homebrew and install mono-libgdiplus
brew update && brew install mono-libgdiplus# Update Homebrew and install mono-libgdiplus
brew update && brew install mono-libgdiplusSHELL
- 更多信息请参阅官方.NET 文档。
准备开始了吗?
Nuget 下载 5,246,844 | 版本: 2025.12 刚刚发布






