Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
791 views
in Technique[技术] by (71.8m points)

The type initializer for 'Gdip' threw an exception in kubernetes pods with C#.net core

I'm calculating the width and height of an image using System.Drawing.Common. Logic is completely working fine in Windows machine. When I deployed it on Linux Server by creating Kuberenetes Pods , Im getting the "The type initializer for 'Gdip' threw an exception". Is there any way to fix this issue from C# side . Not interested to add/modify build scripts


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Is there any way to fix this issue from C# side . Not interested to add/modify build scripts

No. System.Drawing.Common has platform dependencies. They are always there on Windows, but must be installed on Linux.

NOTE that on Ubuntu (and other Linuxes) you may need to install some native dependencies as System.Drawing sits on top of native libraries

sudo apt install libc6-dev
sudo apt install libgdiplus

https://www.hanselman.com/blog/how-do-you-use-systemdrawing-in-net-core


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...