我刚刚尝试在我的C#项目中使用Magick.NET(Q16,AnyCpu)。我通过Monodevelop中的nuget安装它(我在linux上),并试图用我的代码在我的项目中测试它:
using ImageMagick;
// ...
MagickImage img = new MagickImage(requestedPath);
img.Thumbnail(new MagickGeometry(thumbnailWidth, thumbnailHeight));
cycle.Response.ContentType = "image/webp";
img.Write(httpContext.Response.OutputStream, MagickFormat.WebP);
img.Dispose();
...但我在第一行遇到了例外。奇。这是堆栈跟踪的相关部分:
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'X64' threw an exception. ---> System.EntryPointNotFoundException: SetDllDirectory
at (wrapper managed-to-native) ImageMagick.NativeLibraryLoader+NativeMethods:SetDllDirectory (string)
at ImageMagick.NativeLibraryLoader.ExtractLibrary () <0x4089f680 + 0x0009b> in <filename unknown>:0
at ImageMagick.NativeLibraryLoader.Load () <0x4089f640 + 0x00027> in <filename unknown>:0
at ImageMagick.MagickSettings+NativeMethods+X64..cctor () <0x4089f530 + 0x0000b> in <filename unknown>:0
--- End of inner exception stack trace ---
at ImageMagick.MagickSettings+NativeMagickSettings..ctor () <0x4089f3e0 + 0x00017> in <filename unknown>:0
at ImageMagick.MagickSettings..ctor () <0x4089efb0 + 0x000a7> in <filename unknown>:0
at ImageMagick.MagickImage..ctor () <0x4089eee0 + 0x00033> in <filename unknown>:0
at ImageMagick.MagickImage..ctor (System.String fileName) <0x4089ee90 + 0x00017> in <filename unknown>:0
...
这里发生了什么?
答案 0 :(得分:2)
Magick.NET目前仅适用于Windows。有计划在.NET Core版本的Magick.NET中添加对Linux的支持。在撰写本文时,不知道何时会发生这种情况。
编辑:已添加对Linux的支持。对Mac的支持仍在todo列表中。