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:
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
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.
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.