使用 libgdiplus 與 IronOCR:設定指南
This article was translated from English: Does it need improvement?
Translated
View the article in English
.NET Core 需要 libgdiplus 才能使用 Microsoft System.Drawing.Com/mon NuGet 套件。 若在 macOS 或 Linux 上找不到該檔案,您可能會遇到此例外情況:
- 未處理的例外。 System.DllNotFoundException:無法從任何名稱中找到或載入原生函式庫:[ libgdiplus, libgdiplus.so ]
- 若您看到
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception,,請改為閱讀我們的《NET6 中 System.Drawing.Com/mon 指南》。
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-dev
SHELL
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-dev
macOS
若您在 macOS 上遇到以下例外情況:
發生未處理的例外。 System.DllNotFoundException:無法從任何名稱中找到或載入原生函式庫:[ libgdiplus, libgdiplus.dylib ]
您可以透過以下方式解決此問題:
- 將 runtime.osx.10.10-x64.Co/reCompat.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-libgdiplus
SHELL
- 更多資訊請參閱官方 .NET 文件。
準備開始了嗎?
Nuget 下載 5,896,332 | 版本: 2026.5 just released

