6

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

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

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 未处理

Ghostscript.NET.dll 中出现“Ghostscript.NET.GhostscriptLibraryNotInstalledException”类型的未处理异常

附加信息:此托管库在 32 位进程下运行,需要在此机器上安装 32 位 Ghostscript 本机库!要下载适当的 Ghostscript 本机库,请访问:http ://www.ghostscript.com/download/gsdnld.html

截屏

查找Ghostscript.NET.GhostscriptLibraryNotInstalledException并没有提供任何有用的信息,尽管CodeProject 上的这篇文章表明调试器在 32 位模式下运行,而我安装了 64 位版本。

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

4

2 回答 2

8

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

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

于 2016-02-04T10:56:04.597 回答
7

你真的安装了 Ghostscript 吗?

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

“这个托管库在 32 位进程下运行,需要在这台机器上安装 32 位 Ghostscript 本机库!要下载正确的 Ghostscript 本机库,请访问:http ://www.ghostscript.com/download/gsdnld.html ”

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

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

于 2015-12-24T16:53:02.967 回答