32 位进程下的 GhostscriptLibraryNotInstalledException 运行 需要本机库

GhostscriptLibraryNotInstalledException running under 32-bit process requires native library

在 Visual Studio 2013 年使用 nuget,我在我的 Windows x64 PC 上将 Ghostscript.NET 安装到我的项目中。

为了确保我没有发疯,我检查了一下:

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

PM> 

该项目被多个开发者使用。它以任何 CPU 为目标,并且需要保持这种状态。

这是我的代码:

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());
}

每当我尝试调试应用程序时,都会收到以下错误消息:

GhostscriptLibraryNotInstalledException 未处理

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

查找 Ghostscript.NET.GhostscriptLibraryNotInstalledException did not provide any useful information, though this post on CodeProject 表明调试器 运行 处于 32 位模式,而我安装的是 64 位版本。

这些都很好,但我该如何测试我编写的使用 Ghostscript 的新代码?

你真的安装了 Ghostscript 吗?

Ghostscript.NET 只是 Ghostscript 的一个 .NET 接口,在我看来它像消息:

"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"

试图告诉您您没有安装 32 位版本的 Ghostscript。它甚至会告诉您去哪里下载副本。

那么你安装了 Ghostscript 了吗?您是否安装了 32 位版本的 Ghostscript?

如果您正在使用 MS Test 进行测试,则必须设置测试 运行 的处理器架构,因为 Ghostscript.Net 会验证进程架构 (Environment.Is64BitProcess) 以搜索 ghostscript在注册表中安装。

在菜单 > 测试 > 测试设置 > 默认处理器架构 > X64 中。