將 libgdiplus 與 IronOCR 結合使用:設定指南

This article was translated from English: Does it need improvement?
Translated
View 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-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 ]_

您可以透過以下方式解決此問題:

# 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
柯蒂斯·週
技術撰稿人

Curtis Chau擁有卡爾頓大學電腦科學學士學位,專長於前端開發,精通Node.js、TypeScript、JavaScript和React。他熱衷於打造直覺美觀的使用者介面,喜歡使用現代框架,並擅長撰寫結構清晰、視覺效果出色的使用者手冊。

除了開發工作之外,柯蒂斯對物聯網 (IoT) 也抱有濃厚的興趣,致力於探索硬體和軟體整合的創新方法。閒暇時,他喜歡玩遊戲和製作 Discord 機器人,將他對科技的熱愛與創造力結合。

準備好開始了嗎?
Nuget 下載 5,299,091 | 版本: 2025.12 剛剛發布