ghostscriptsharp icon indicating copy to clipboard operation
ghostscriptsharp copied to clipboard

Azure Issue

Open Mayhem351 opened this issue 11 years ago • 11 comments

In dev it works fine, butit fails to create the image when it's live on Azure hosting, no error is thrown. Edit: No error was thrown because of a async control used. Error output was the same Unable to load DLL 'gsdll32.dll'

Mayhem351 avatar Jan 14 '15 13:01 Mayhem351

I ran into the same problem. More than likely you need to add the dll to your web project root and mark it "Copy If Newer"

davesheldon avatar Feb 13 '15 22:02 davesheldon

I have tried loading the gsdll32.dll one thousand different ways but I always get the FileNotFound Exception. It is a very weird bug when published into Azure. Locally I can easily get the path of the Bin folder, but when published the path can't find the file.

zerocold96 avatar Sep 01 '15 14:09 zerocold96

You may have to add it directly to your web project and mark it "copy always" or "copy of newer". On Tue, Sep 1, 2015 at 10:55 AM zerocold96 [email protected] wrote:

I have tried loading the gsdll32.dll one thousand different ways but I always get the FileNotFound Exception. It is a very weird bug when published into Azure. Locally I can easily get the path of the Bin folder, but when published the path can't find the file.

— Reply to this email directly or view it on GitHub https://github.com/mephraim/ghostscriptsharp/issues/15#issuecomment-136750822 .

davesheldon avatar Sep 01 '15 14:09 davesheldon

I added a comment that mentioned you need to have the gsdll32.dll listed an embedded resource so that it would be in the bin, and the location in the bin would be /bin/<any_path_from_root_of_web_project>/gsdll32.dll. Placing it at the web project root would make the path /bin/gsdll32.dll. This was the only way that I was able to get it to work.

i-love-code avatar Sep 01 '15 16:09 i-love-code

Ok, will try. (FYI, I have had the same issues with: GhostscriptSharp, Ghostscript.NET, and just manually adding gsdll32.dll by using an FTP client.)

Wanted to respond earlier, but internet decided to die.

this what I get when I try to load the assembly with: Assembly.Load("gsdll32.dll") <ExceptionMessage> Could not load file or assembly 'gsdll32.dll' or one of its dependencies. The system cannot find the file specified. </ExceptionMessage> <ExceptionType>System.IO.FileNotFoundException</ExceptionType>

the DLL was added as embedded resource with copy newest.

I am trying to load using Ghoscript.NET: With path obtain as: HttpContext.Current.Server.MapPath("~/bin") and adding @"/gsdll32.dll" to string path

Error: <ExceptionMessage>Ghostscript native library could not be found.</ExceptionMessage> <ExceptionType>System.DllNotFoundException</ExceptionType>

Can you please show me how you loaded the DLL? Or did you just embedded it as resource and GhostScriptSharp found it? will try using ghostscriptsharp again.

zerocold96 avatar Sep 01 '15 17:09 zerocold96

For debugging purposes, can you connect to your Azure site via FTP and show a picture of the files in the web root as well as the bin folder?

Also, if your Azure site is running in 64bit mode, try adding gsdll64.dll to the folder as well. I have both in my project as I need to support developers and servers on both platforms, just make sure to switch between them based on environment.

i-love-code avatar Sep 01 '15 17:09 i-love-code

OK: bin root

I had both 32 and 64 bit in there before, but took them out as 32 was the only one being call.

zerocold96 avatar Sep 01 '15 17:09 zerocold96

This is driving me insane.. Where did you download the DLLs? maybe I got corrupted ones.

zerocold96 avatar Sep 01 '15 17:09 zerocold96

I'm actually using GhostScript.NET Version 1.2 to accomplish what I need, but was using GhostscriptSharp in the past. Here's the code I am using currently for GS.NET.

var dllLocation = Environment.Is64BitProcess ? "bin\\gsdll64.dll" : "bin\\gsdll32.dll"; // For some reason this wasn't working on its own, so I did it myself.

var ghostScriptDllLocation = string.Concat(AppDomain.CurrentDomain.BaseDirectory, dllLocation);
GhostscriptVersionInfo version = new GhostscriptVersionInfo(new Version(0, 0, 0), ghostScriptDllLocation,
            string.Empty, GhostscriptLicense.GPL);
using (rasterizer = new GhostscriptRasterizer())
{
      rasterizer.Open(pdfStream, version, false);
}

i-love-code avatar Sep 01 '15 18:09 i-love-code

I copy pasted your code; only major difference would be your path when compare to what I had before. Download the gsdll32.dll and gsdll64.dll from GitHub Embedded Resource. I checked using FTP and the DLLs are inside the bin directory. When I test the function from azure I get:

<ExceptionMessage>Ghostscript native library could not be found.</ExceptionMessage> <ExceptionType>System.DllNotFoundException</ExceptionType>

Which is just plain weird. The library I am using is GS.NET Version 2.0 installed from NUGET.

I don't know what to do anymore... This is a mobile backend, I don't know if that even matters.

zerocold96 avatar Sep 01 '15 20:09 zerocold96

You could try deploying a basic web application to Azure with your code to isolate it being a Mobile Backend issue.

i-love-code avatar Sep 01 '15 20:09 i-love-code