1

There are two symptoms of what I believe is the same issue.

I've installed GhostScriptSharp using Nuget and I'm running it locally on a 32-bit maching in the Azure Development Fabric. Everything is working wonderfully.

When I deploy to Azure, which is 64-bit, I'm getting the following error message.

Unable to load DLL 'gsdll32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

There are two issues here as I can tell

  • The project did not build with the 64-bit GhostScriptSharp.cs
  • Regardless of the build, the gsdll32.dll or gsdll64.dll is not being copied into the correct folder.

Are there any recommendations to get this working on the Azure deployments?

Skenflow
  • 129
  • 1
  • 9
  • You could try to use Ghostscript.NET: https://ghostscriptnet.codeplex.com/ – HABJAN Jul 02 '14 at 05:08
  • Thanks for the suggestion. We will take a look at it. Can you confirm that Ghostscript.NET is using the AGPL license? – Skenflow Jul 02 '14 at 17:45
  • yes, I can confirm that it's AGPL from v.1.1.6. on. – HABJAN Jul 03 '14 at 06:17
  • @HABJAN: I though you were meant to declare when you have a vested interest in a product you promote on SO? I see you are "the" jhabjan that created ghostscriptnet :) – iCollect.it Ltd Dec 23 '15 at 10:38
  • @TrueBlueAussie: not sure if I understood what you wanted to say. :-) Yep, I'm that person. Pretty busy for the last couple of months so I did not have too much time to dedicate to Ghostscript.NET. – HABJAN Dec 23 '15 at 16:19
  • If you write a package and you recommend it yourself (i.e. self-promotion) you are supposed to state something like "Note: I am the author of GhostscriptNet" so we know the recommendation is not unbiased :) – iCollect.it Ltd Dec 23 '15 at 16:22

2 Answers2

4

Just had to solve this on an Azure website deployment for a test site. We only use GhostScriptSharp for the thumbnailing features and have not figured out how to do the same with Ghostscript.NET as practical examples are light on the ground.

The error message is slightly misleading. The file is not missing, it just does not have read/write access to the folder in which the DLL files were located (e.g. your BIN folder).

If you were running on a VM you could give read/write access to your BIN folder (slight security problem), but on free Azure websites you do not have that control.

Our solution was to place the gsdll32.dll and gsdll64.dll files into the App_Data folder (which already has read/write access) and add that folder to the places searched for DLLs using the Win32 kernel SetDllDirectory function.

e.g. declare it using

[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);

Then, before calling the GhostscriptSharp methods, e.g. from within your controller method, add the App_Data folder to the DLL search paths using:

SetDllDirectory(Server.MapPath("~/App_Data/"));

After this it just started working again.

iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
  • Sadly I attempted this and my website still couldnt find the dll – misha130 Feb 16 '16 at 15:44
  • @misha130: I am assuming you placed the DLL files in {webroot}/App_Data under your project? It only takes one missing step from the above to stop it working. Does it work locally before you try this? – iCollect.it Ltd Feb 16 '16 at 15:47
  • Yeap, I set it to App_Data.It worked locally when I had gs installed. But to be frank I am using GhostScript.Net and not Sharp so maybe thats why – misha130 Feb 16 '16 at 15:50
  • @misha130: That will make a difference. This solution is only for Ghostscript sharp. Suggest you talk to `HABJAN` in the early comments on the question as he wrote GhostScript.net and may be able to help you :) – iCollect.it Ltd Feb 16 '16 at 16:01
-1

It is possible that you are missing some windows runtime DLLs that exist on the development machine. These would need to be included in your deployment to Azure.

  • The dlls are not copying during the deployment. I did rdp into the vm and downloaded the required dlls. When the 64-bit is available, I still get the same error because I don't believe the GhostScriptSharp is built using the 64-bit import statements. When I place the 32-bit dll on the server, I get an incorrect format error. Hopefully that helps a bit more. – Skenflow Jul 02 '14 at 17:47