OS X に macports でインストールした mono で Graphics や Forms を使うための設定
OS X (10.5.6) に macports で mono をインストールしたはいいが、Windows.Forms や System.Drawing なアプリを動かすために設定が必要だったのにビックリしたので、備忘録をかねてメモ。
ためした環境
% mono -V Mono JIT compiler version 2.0.1 (tarball) Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com TLS: normal GC: Included Boehm (with typed GC) SIGSEGV: normal Notification: Thread + polling Architecture: x86 Disabled: none
% port version Version: 1.700
% port info mono mono @2.0.1 (devel, lang, mono) Variants: darwin_9, universal Mono is an effort to create an open source implementation of the .NET Development Framework including a C# compiler. Homepage: http://www.go-mono.com/ Build Dependencies: pkgconfig, gawk Library Dependencies: gettext, glib2, libiconv, zlib, libgdiplus, XFree86 Platforms: darwin Maintainers: mww@macports.org
設定しておかないとこういうエラーが出る
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for wizz.swimmy._081126.EntryPointForm ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.WindowsFormsSynchronizationContext ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeWin32Classic ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.KnownColors ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: gdiplus.dll
必要だった設定
% cat ~/.mono/config <configuration> <dllmap dll="gdiplus.dll" target="/opt/local/lib/libgdiplus.dylib"/> </configuration>
要するに、libgdiplus がインストールされているだけでなく、gdiplus.dll の対応先(libgdiplus.dylib)がどこなのかを mono ランタイムに伝えてやる必要があるようだ。