How to P/Invoke to a native dll from Metro?
I've got a library consisting of two parts - One .net assembly that P/Invokes to a native 3rd party dll. In desktop mode this works just fine: However, when referencing the assembly from a Metro style app and running it, it throws a System.DllNotFoundException
on the P/Invoke complaining that "Unable to load DLL 'library': The specified module could not be found."
The native dll does not do anything special but only creates out-going TCP/IP connections to a server. The system cannot know this, but rather the native dll could do anything. This is why I suspect it might not be possible to do this.
Some dll search order is mentioned on msdn regarding Metro style apps, hinting about it is possible to load native dlls?
Also I found this link on msdn talking about loading "libraries" and mentions the PackageDependency in the manifest file, but to me it's still unclear how to add a native dll to the package in a way that it is possible to P/Invoke it.
将它添加到您的项目中(右键单击项目,添加,现有项目)。检查该项目的属性中,Content设置为True(默认为false)。
This is probably by design. Your problem might be caused by an error with error code 126 being returned from LoadLibrary. If your application runs in desktop mode you should target desktop mode for your application. You might use an earlier version of Windows as well.
链接地址: http://www.djcxy.com/p/44468.html上一篇: 非托管DLL的相对路径
下一篇: 如何P /从地铁调用到本机DLL?