Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GhostscriptLibraryNotInstalledException running under 32-bit process requires native library

Using nuget in Visual Studio 2013, I installed Ghostscript.NET into my project on my Windows x64 PC.

Just to make sure I wasn't crazy, I checked it:

PM> Install-Package Ghostscript.NET
'Ghostscript.NET 1.2.0' already installed.
Project already has a reference to 'Ghostscript.NET 1.2.0'.

PM> 

The project is used by multiple developers. It targets Any CPU, and needs to remain that way.

Here is my code:

public static void GhostscriptNetProcess(String fileName, String outputPath)
{
    var version = GhostscriptVersionInfo.GetLastInstalledVersion();
    var source = (fileName.IndexOf(' ') == -1) ? fileName : String.Format("\"{0}\"", fileName);
    var output_file = (outputPath.IndexOf(' ') == -1) ? outputPath : String.Format("\"{0}\"", outputPath);
    var gsArgs = new List<String>();
    gsArgs.Add("-q");
    gsArgs.Add("-dNOPAUSE");
    gsArgs.Add("-dNOPROMPT");
    gsArgs.Add("-sDEVICE=pdfwrite");
    gsArgs.Add(String.Format(@"-sOutputFile={0}", output_file));
    gsArgs.Add("-f");
    gsArgs.Add(source);
    var processor = new GhostscriptProcessor(version, false);
    processor.Process(gsArgs.ToArray());
}

Whenever I attempt to debug the application, I get the following error message:

GhostscriptLibraryNotInstalledException was unhandled

An unhandled exception of type 'Ghostscript.NET.GhostscriptLibraryNotInstalledException' occurred in Ghostscript.NET.dll

Additional information: This managed library is running under 32-bit process and requires 32-bit Ghostscript native library installation on this machine! To download proper Ghostscript native library please visit: http://www.ghostscript.com/download/gsdnld.html

screenshot

Looking up the Ghostscript.NET.GhostscriptLibraryNotInstalledException did not provide any useful information, though this post on CodeProject indicated that the debugger is running in 32-bit mode whereas I have the 64-bit version installed.

That's all well and good know, but how do I go about testing the new code I wrote that uses Ghostscript?

like image 369
jp2code Avatar asked Dec 24 '15 14:12

jp2code


2 Answers

If you are testing with MS Test you have to set the processor architecture in which the tests are run, because Ghostscript.Net verifies the process architecture (Environment.Is64BitProcess) to search for the ghostscript installation in the registry.

In Menu > Test > Test Settings > Default Processor Architecture > X64.

like image 166
Miguel de Sousa Avatar answered Nov 03 '22 01:11

Miguel de Sousa


Have you actually installed Ghostscript ?

Ghostscript.NET is merely a .NET interface to Ghostscript, it looks to me like the message:

"This managed library is running under 32-bit process and requires 32-bit Ghostscript native library installation on this machine! To download proper Ghostscript native library please visit: http://www.ghostscript.com/download/gsdnld.html"

is trying to tell you that you don;t have a 32-bit version of Ghostscript installed. It even tells you where to go to download a copy.

So have you installed Ghostscript ? Have you installed the 32-bit version of Ghostscript ?

like image 45
KenS Avatar answered Nov 03 '22 00:11

KenS