6

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?

Community
  • 1
  • 1
  • It seems that your project is set as x86 (32 bit), which would need 32 bit native Ghostscript library installed on that machine... or change your project to Mixed ( x86/x64 )- – HABJAN Dec 24 '15 at 14:40
  • I can't get the 32-bit version to install or the source code to extract. See [Ghostscript Bug 696481](http://bugs.ghostscript.com/show_bug.cgi?id=696481). –  Dec 24 '15 at 14:43

2 Answers2

8

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.

Miguel de Sousa
  • 324
  • 2
  • 15
  • I have followed this process. But still now getting same error – Sonali Feb 14 '18 at 06:43
  • 2
    I have downloaded gs922w32.exe from https://www.ghostscript.com/download/gsdnld.html. and installed it. Now it is working – Sonali Feb 14 '18 at 06:59
7

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 ?

KenS
  • 30,202
  • 3
  • 34
  • 51