简体   繁体   English

Vista DLL导入问题C#

[英]Vista DLLImport Problem C#

[DllImport("DoSomething.dll", EntryPoint = "something_dump", SetLastError = true)] private static extern void something_dump(IntPtr dumper); [DllImport(“ DoSomething.dll”,EntryPoint =“ something_dump”,SetLastError = true)]私有静态外部无效something_dump(IntPtr dumper);

When I run this DLLImport on XP machines it works fine but on vista I recieve the exception: 当我在XP计算机上运行此DLLImport时,它工作正常,但在Vista上,我收到了以下异常:

Unable to load DLL 'DoSomething.dll': The specified module could not be found. 无法加载DLL'DoSomething.dll':找不到指定的模块。 (Exception from HRESULT: 0x8007007E) (来自HRESULT的异常:0x8007007E)

On both machines its located in the Windows/System32 directory, but for some reason vista doesn't load it. 在两台计算机上,它都位于Windows / System32目录中,但是由于某种原因,vista不会加载它。

And when I fully qualify the path on the vista machine ...DllImport("C:\\WINDOWS\\system32\\DoSomething.dll"... It works! 当我完全限定Vista机器上的路径时... DllImport(“ C:\\ WINDOWS \\ system32 \\ DoSomething.dll” ...它起作用了!

Do I actually have to tell the DLLImport function on the vista machine to look in the system32 directory? 我是否真的必须告诉Vista机器上的DLLImport函数在system32目录中查找?

The problem is someone was coping the dll to the current solutions output directory... The problem being they didn't copy the dll's dependencies to the output directory... So somehow XP could resolve those dependences and Vista would fail. 问题是有人将dll压缩到当前解决方案的输出目录中。问题是他们没有将dll的依赖项复制到输出目录中。所以XP可以解决这些依赖关系,而Vista可能会失败。 (The dll is the exact same on both os's) (dll与两个OS完全相同)

Solution: Remove the coping of system dll's to the current solutions output directory... 解决方案:删除系统dll到当前解决方案输出目录的应对方法...

Place you Dll into "document settings\\administrator\\" this path to work. 将您的Dll放入“文档设置\\管理员\\”此路径下即可工作。

Make note you need to place all supporting files example .ino or .txt files support to that dll also. 请注意,您还需要将所有支持文件(例如.ino或.txt文件支持)也放置到该dll中。

It will work fine. 它将正常工作。

All the best. 祝一切顺利。

Regards, Prasath 问候,Prasath

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM