Stavros_S Stavros_S - 1 month ago 7x
C# Question

Starting ImageMagick process on windows server failing with "the specified module could not be found."

I'm using ImageMagick to convert PDF files to PNG. Running the process from my Web API project locally works as long as I run Visual Studio as admin. When moving the solution to the server the ImageMagick process fails with the following error

convert.exe: unable to load module `C:\Program
Files\ImageMagick-6.9.0-Q16\modules\coders\IM_MOD_RL_PNG_.dll': The
specified module could not be found.

I have both ghostscript and ImageMagick installed as they should be on the server. What could be a cause for this? I can verify that the module does in fact exist on the server.


The solution to this problem in my situation was to set the environment variable for ImageMagick directly in the code where I was calling the process.

System.Environment.SetEnvironmentVariable("Path", @"C:\Program Files\ImageMagick-6.9.0-Q16");

Apparently even if the environment variable is set on the server, it may not find it due to the runtime being different.