Upgraded to latest ImageMagick / Magick.NET (7.0.2.901), and it built and ran fine locally, but explodes on the server with this error.
Unable to find an entry point named 'Environment_SetEnv' in DLL 'Magick.NET-Q8-x64.Native.dll'.
Seems to be a new issue. Judging by the change desc here:
https://magick.codeplex.com/discussions/650746
The VC Runtimes are no longer required, so installing them wouldn't be the issue - and, I've installed 2008, 2012 and 2015 VC runtimes for prior versions of the library, which worked fine.
Windows Server 2008 64-bit, 64-bit .Net 4 in IIS.
Current workaround is to roll back to 7.0.0.22, which runs without error.
Install-Package Magick.NET-Q8-AnyCPU -Version 7.0.0.22
I had this issue a couple months back and eventually found two separate causes:
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.
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
Follow these steps:
Go to NuGet package manager for the solution (not the project)
Uninstall any previous versions of Magick.net
Install new version of Magick.net to desired projects
Go to the bin
folder of the main project and delete any magick.net file
Run your solution
I successfully tested this method on VS2017 and Magick.net 7.6.1 (previous installation was 7.4.4)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With