Vista DLLImport Problem C#

[DllImport("DoSomething.dll", EntryPoint = "something_dump", SetLastError = true)] private static extern void something_dump(IntPtr dumper);

When I run this DLLImport on XP machines it works fine but on vista I recieve the exception:

Unable to load DLL 'DoSomething.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

On both machines its located in the Windows/System32 directory, but for some reason vista doesn't load it.

And when I fully qualify the path on the vista machine ...DllImport("C:WINDOWSsystem32DoSomething.dll"... It works!

Do I actually have to tell the DLLImport function on the vista machine to look in the system32 directory?


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. (The dll is the exact same on both os's)

Solution: Remove the coping of system dll's to the current solutions output directory...


Place you Dll into "document settingsadministrator" this path to work.

Make note you need to place all supporting files example .ino or .txt files support to that dll also.

It will work fine.

All the best.

Regards, Prasath

链接地址: http://www.djcxy.com/p/7736.html

上一篇: SharePoint无法在Windows 2008上加载C ++ DLL

下一篇: Vista DLLImport问题C#