● System.Drawing .NET Core on Mac/linux, GDIPlus Exception
Problem
I got the whole thing up and running in debug. But when I went for our dotnet run, I got the following crash:
The type initializer for 'Gdip' threw an exception.
Solution
After googling a bit, I found out that macs have a brew package for the GDI+ good to go.
MacOS
brew install mono-libgdiplus
项目nuget引用CoreCompat.System.Drawing
。
注意mono-libgdiplus和CoreCompat.System.Drawing与.net对用的版本。
Linux7
yum install libgdiplus-devel
ln -s /usr/lib64/libgdiplus.so /usr/lib/gdiplus.dll
ln -s /usr/lib64/libgdiplus.so /usr/lib64/gdiplus.dll
Ubuntu
sudo apt-get install libgdiplus
ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll