Load C library (gsdll32.dll) from Metro Style App

2019-05-07 08:31发布

I want to use gsdll32.dll from Metro Style App c#. I load dll as follow:

[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);

But when I try to load dll not found exception occurs. I have already put it in Debug file. But it does work.

I reference from this link.

2条回答
何必那么认真
2楼-- · 2019-05-07 09:06

It is possible, but:

  • Was gsdll32.dll compiled against the WinRT SDK?
  • Does gsdll32.dll passes the App certification?
  • Did you include the dll in your package?

If the answer to any of those questions is "no", then your code will not work.

查看更多
Deceive 欺骗
3楼-- · 2019-05-07 09:28

Build Ghostscript from source (PC version)
Microsoft Environment for WinRT

Ghostscript can be built in the form of a win32 DLL for use within a Windows Runtime application or Windows Runtime component. Building for WinRT requires use of Microsoft Visual Studio 2012. There is a solution file that can be loaded into VS 2012, in the directory winrt

The WinRT application or component should include iapi.h from gs/psi and link with gsdll32metro.lib from gs/debugbin or gs/releasebin. Also any app using ghostscript either directly or via a component should add gsdll32metro.dll as "content". This inclusion of the dll is necessary so that it will be packaged with the app. If one wishes to be able to run the debugger on ghostscript then gsdll32metro.pdb should also be added as content.

From the GhostScript 9.21 documentation

Yes, I do realize this question is half a decade old.

查看更多
登录 后发表回答