从Metro Style App c#加载C库(gsdll32.dll)

我想使用Metro Style App c#中的gsdll32.dll。 我加载DLL如下:

[DllImport("gsdll32.dll", EntryPoint = "gsapi_delete_instance")] private static extern void gsapi_delete_instance(IntPtr instance); [DllImport("gsdll32.dll", EntryPoint = "gsapi_revision")] private static extern int gsapi_revision(ref GS_Revision pGSRevisionInfo, int intLen); [DllImport("gsdll32.dll", EntryPoint = "gsapi_set_stdio")] private static extern int gsapi_set_stdio(IntPtr lngGSInstance, StdioCallBack gsdll_stdin, StdioCallBack gsdll_stdout, StdioCallBack gsdll_stderr); 

但是当我尝试加载dll时没有发现exception发生。 我已经把它放在Debug文件中了。 但它确实有效。

我从这个链接中引用。

这是可能的,但是:

  • 是针对WinRT SDK编译的gsdll32.dll吗?
  • gsdll32.dll是否通过了App认证?
  • 你是否在包中加入了dll?

如果任何这些问题的答案都是“否”,那么您的代码将无效。

从源代码构建Ghostscript(PC版)
WinRT的Microsoft环境

Ghostscript可以以win32 DLL的forms构建,以便在Windows运行时应用程序或Windows运行时组件中使用。 构建WinRT需要使用Microsoft Visual Studio 2012.有一个解决方案文件可以加载到VS 2012,在winrt目录中

WinRT应用程序或组件应包含来自gs / psi的iapi.h,并与gs / debugbin或gs / releasebin中的gsdll32metro.lib链接。 此外,任何直接或通过组件使用ghostscript的应用程序都应将gsdll32metro.dll添加为“内容”。 包含dll是必要的,以便与应用程序一起打包。 如果希望能够在ghostscript上运行调试器,那么gsdll32metro.pdb也应该作为内容添加。

从GhostScript 9.21文档

是的,我确实意识到这个问题已有五十年了。