【问题标题】:Load C library (gsdll32.dll) from Metro Style App c#从 Metro Style App c# 加载 C 库 (gsdll32.dll)
【发布时间】:2012-10-02 06:38:53
【问题描述】:

我想使用 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 时出现未找到异常。我已经把它放在调试文件中。但它确实有效。

我引用自this link

【问题讨论】:

  • 另一种方式,我想知道是否可以从 Metro Style App 引用和加载 c 库 dll。
  • 于丽,你说yms的回答对你有帮助。那么您能否“接受”并“投票”他的回答?
  • 好的,Kurt Pfeifle,我做到了。谢谢。

标签: c# pdf microsoft-metro dllimport ghostscript


【解决方案1】:

有可能,但是:

  • gsdll32.dll 是否针对 WinRT SDK 编译?
  • gsdll32.dll是否通过App认证?
  • 您的软件包中是否包含该 dll?

如果其中任何一个问题的答案是“否”,那么您的代码将无法正常工作。

【讨论】:

  • 1)Nope.gsdll32.dll 是 Win32 c 库。 2)不 3)我如何包括?如果可能,请按步骤告诉我或提供示例。
  • 不能在 WinRT 应用程序中使用 GhostScript,仅此而已。
  • 非常感谢。我很清楚 GhostScript 不能在 WinRT 中使用。是不是意味着所有的Win32 dll都不能在WinRT中使用?
  • 有点……你总是不得不到处修改代码,并删除对 WinRT 中“禁止”的 Win32 API 函数的任何调用(而且大多数都是)。
  • 非常感谢。这对我很有帮助。
【解决方案2】:

从源代码构建 Ghostscript(PC 版)
微软 WinRT 环境

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

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

来自GhostScript 9.21 documentation

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-14
    相关资源
    最近更新 更多