IronOCRでlibgdiplusを使用する: セットアップガイド
.NET Core では、Microsoft System.Drawing.Common NuGet パッケージを使用するためにlibgdiplusが必要です。 macOS または Linux で見つからない場合は、次の例外が発生する可能性があります。
- 未処理の例外。 System.DllNotFoundException: どの名前からもネイティブライブラリが見つからないか、読み込めませんでした: [ libgdiplus, libgdiplus.so ]
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception,代わりにNET6 の 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ドッカー
必要なライブラリが Docker イメージに含まれていることを確認するには、Dockerfile に次の行を追加します。
# 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 ]
この問題を解決するには、次の手順に従ってください。
- libgdiplus をプロジェクトに含めるには、 runtime.osx.10.10-x64.CoreCompat.System.Drawing NuGet パッケージを .NET ソリューションに追加します。
- あるいは、以下のコマンドを使用して 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- 詳細については、公式の.NET ドキュメントをご覧ください。






