Running under IIS AppPool Identity?

Jul 24, 2014 at 4:20 AM
Has anyone managed to get Magick.NET to run under an IIS AppPool Identity? I can't seem to figure out what permissions I need to set to allow this to work. If I run the site under a privileged user it will work so I know it's permissions of some description. I found that it needs to be able to write to the temp environment folder and have given that access but there m,ust be something else

The errors I get are:
  • Failed to load embedded assembly: The type initializer for 'ImageMagick.MagickNET' threw an exception.
Inner exception:
  • Magick: Error when saving the profile into a file '.' @ warning/opencl.c/autoSelectDevice/2303
Thanks in advance,

Jul 24, 2014 at 5:21 AM
I think it's coming from SetUseOpenCL(Boolean value) see a very inner stack trace

at ImageMagick.MagickException.Throw(Exception* exception)
at ImageMagick.MagickNET.SetUseOpenCL(Boolean value)
at ImageMagick.MagickNET..cctor()

I have tried setting the environment variable MAGICK_OCL_DEVICE to off as per below but it doesn't help.
  • Environment.SetEnvironmentVariable("MAGICK_OCL_DEVICE", @"off");
Jul 24, 2014 at 6:26 AM
Another update, it will run under Local System but not Network Service or Local Service or the AppPool Identity
Jul 24, 2014 at 7:11 AM
It is coming from then SetUseOpenCL method. At this moment it needs write access to the following directory: %LOCALAPPDATA%. The next release of Magick.NET will no longer set the OpenCL property from the static constructor. And I will add a method to set the OpenCL cache directory so you can use a directory other then %LOCALAPPDATA%.
Jul 24, 2014 at 7:46 AM
Okay I've answered my own question now but I'll put it here as someone is bound to have the same issue at some stage

It seems to need access to
  • C:\Windows\System32\config\systemprofile\AppData\Local
It then has under it
  • C:\Windows\System32\config\systemprofile\AppData\Local.config\ImageMagick
In this folder it seems to store OpenCL informations (files):
  • ImagemagickOpenCLDeviceProfile
  • magick_opencl________Intel(R)_Core(TM)_i7-3517U_CPU_@_1.90GHz_00_217c3295_64.bin (This would seem specific to my machine)
I'm guessing that it may have needed even higher privilege to create this initially as when I first used Magick.NET I was running under a high privilege account and so it wouldn't have had trouble putting it there or reading other information it needed to create these files.

Hope this helps someone someday.

Jul 24, 2014 at 7:49 AM
dlemstra, just saw your response after I figured it out as per my post.

Sounds, good. I look forward to the next release, in the mean time I can move forward.