我正在尝试在运行于Ubuntu 18.04的.Net Core控制台应用程序中使用System.Drawing.Common创建位图,但是当我执行代码时会显示:
Gdip的类型初始化程序引发了异常。 在System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, HandleRef scan0, IntPtr& bitmap)处 在System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)处 在MidnightBot.Modules.AdminCommands.CreatePollAsync(String Term1, String Term2, String Description) 位置/home/MidnightBot/Modules/AdminCommands.cs:line 125 System.DllNotFoundException: 无法加载DLL 'libgdiplus':找不到指定的模块。 在System.Runtime.InteropServices.FunctionWrapper`1.get_Delegate()处 在System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)处 在System.Drawing.SafeNativeMethods.Gdip..cctor()处
此外,我已经按照这里所述的方法进行了尝试,但并没有成功。
感谢任何帮助。
dotnet restore
可以修复这个问题吗?这应该在编译时就阻止你,而不是在运行时。 - clarkitectsudo apt-get install libgdiplus
- NineBerry