如何P / Invoke来从地铁本地的dll? [英] How to P/Invoke to a native dll from Metro?

查看:100
本文介绍了如何P / Invoke来从地铁本地的dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有由两部分组成的库 - 一个.NET程序集的 P /调用以本地第三方DLL。在桌面模式下,该工作得很好:但是,从Metro风格应用程序引用组装和运行它时,它抛出一个 System.DllNotFoundException 上的的P / Invoke 抱怨无法加载DLL库 :指定的模块找不到

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."

本机DLL并没有做什么特别的事情,但只有创造出持续到服务器的TCP / IP连接。系统无法知道这一点,而是本地的dll可以做任何事情。这就是为什么我怀疑它可能无法做到这一点。

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.

有些DLL搜索顺序提到的<一个href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx#_search_order_for_metro_style_apps__"相对=nofollow> MSDN 有关Metro风格的应用程序,暗示它是可能加载机DLL?

Some dll search order is mentioned on msdn regarding Metro style apps, hinting about it is possible to load native dlls?

另外,我发现这个在MSDN链接的谈加载库,并提到在清单文件中的PackageDependency,但对我来说,目前还不清楚的如何在这样一个本机DLL添加到包中,它是可能的<一个HREF =htt​​p://msdn.microsoft.com/en-us/library/aa288468%28v=vs.71%29.aspx相对=nofollow> P /调用该的。

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.

推荐答案

这可能是设计使然。你的问题可能是一个错误,错误code 126的调用LoadLibrary 。 如果您的应用程序在桌面模式下运行,你应该针对桌面模式的应用程序。您可以使用Windows的早期版本。

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.

这篇关于如何P / Invoke来从地铁本地的dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆