This project has moved and is read-only. For the latest updates, please go here.

Convert PDF to JPEG Access Denied Error...

Apr 22, 2014 at 4:41 PM
When I try to convert a PDF to JPEG, I'm receiving the following error:
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) 

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. 

To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))]
   System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence) +0
   System.Reflection.Assembly.LoadFile(String path) +178
   ImageMagick.AssemblyHelper..cctor() +9

[TypeInitializationException: The type initializer for 'ImageMagick.AssemblyHelper' threw an exception.]
   ImageMagick.AssemblyHelper.GetType(String name) +28
   ImageMagick.Types..cctor() +25

[TypeInitializationException: The type initializer for 'ImageMagick.Types' threw an exception.]
   ImageMagick.MagickReadSettings..ctor() +28
   ImportReceipts._Default.UploadImage() +1040
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
I have looked everywhere but could not find a solution. I have changed some permissions on IIS but still having the same problem....

Thanks for any help...
Apr 22, 2014 at 7:31 PM
It seems you are not allowed to load an assembly from the temp directory. The AnyCPU version of Magick.NET detects if it needs the x86 or the x64 version of the library and saves that dll to the temp directory. It then tries to load that library but it looks like it is not allowed to do that. Maybe I should add a method that will allow you to specify the folder that is being used for that. Can you contact me through CodePlex so I can send you a development version of Magick.NET that has this new option?
Apr 22, 2014 at 7:41 PM
I've used the x-64 version and it worked...