在DLL文件'Magick.NET-Q8-x64.Native.dll'中无法找到名为'Environment_SetEnv'的入口点。

7

已升级到最新的ImageMagick / Magick.NET(7.0.2.901),本地构建和运行正常,但在服务器上出现以下错误:

无法找到名为“Environment_SetEnv”的入口点,位于DLL'Magick.NET-Q8-x64.Native.dll'。

这似乎是一个新问题。根据这里的更改说明:

https://magick.codeplex.com/discussions/650746

不再需要VC Runtimes,因此安装它们不会是问题-我已经为库的早期版本安装了2008、2012和2015 VC运行时,可以正常工作。

操作系统为Windows Server 2008 64位,IIS中使用64位 .Net 4。

当前的解决方法是回退到7.0.0.22版本,可以正常运行。

Install-Package Magick.NET-Q8-AnyCPU -Version 7.0.0.22

ImageMagick.X64.Environment_SetEnv(IntPtr name, IntPtr value)


您介意在这里开个话题吗:https://magick.codeplex.com/discussions?然后我可以向您提问。 - dlemstra
你已经解决了这个问题吗?我在我的服务器上也遇到了同样的问题。虽然本地运行正常。 - Ron Sijm
我想在发布错误之前收集更多的诊断信息,但从未这样做过。事实上,它必须在服务器上爆炸,这使得收集这些诊断信息成为一项更大的任务,因为我真的需要将其放在一个设计失败的网站上。不过我会回来处理的。但是如前所述,解决方法很容易,回滚到7.0.0.22版本即可。 - Chris Moschini
3个回答

8

我之前遇到过这个问题,最终找到了两个不同的原因:

  1. AnyCPU Conflict with Previous Versions

    Problem: Magick.NET caches the native library in a temp directory unless it already exists (Relevant source code). Since I had previously tested with the Q8-x64 version (which doesn't test for CPU architecture), the Magick.NET-Q8-x64.Native.dll already existed and was not overwritten.

    Resolution: Delete the native library's temp directory. On my version of Windows, it was located at %TEMP%\Magick.NET.{TargetFramework}.{MagickNETVersion}. The Q8-AnyCPU version then extracted a new native library with the Environment_SetEnv method.

  2. Lack of Permissions in Cache Directory

    Problem: The native library was cached in a directory with restricted permissions for executing code.

    Resolution: Change the cache directory's location. My solution is the following code.

    #if DEBUG
    private static bool MagickCacheDirectoryIsSet = false;
    
    public DefaultConstructor()
    {
        if (!MagickCacheDirectoryIsSet)
        {
            ImageMagick.MagickAnyCPU.CacheDirectory = @"path\to\more\permissive\directory";
            MagickCacheDirectoryIsSet = true;
        }
    }
    #endif
    

1
我在C:\Windows\Temp中执行了#1,并且按照以下步骤进行操作:https://dev59.com/UmAg5IYBdhLWcg3wrMl5#23308437。然后我重新启动了应用程序池。 - user1325179
我所需要做的就是回收应用程序池。我不需要删除任何临时文件。 - joeshmoe301

1
请按照以下步骤操作:
  1. 前往NuGet包管理器,针对解决方案(而非项目)

  2. 卸载任何先前版本的Magick.net

  3. 将新版本的Magick.net安装到所需项目中

  4. 前往主项目的bin文件夹并删除任何magick.net文件

  5. 运行您的解决方案

我已在VS2017和Magick.net 7.6.1上成功测试了此方法(之前的安装版本为7.4.4)


0

我曾经遇到过同样的问题,将bin文件夹中的所有magick dlls删除并重新安装后解决了这个问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接