How to call win32 dll in windows 7

≡放荡痞女 提交于 2020-01-02 07:37:14

问题


From within a C# application(Visual Studio 2008) i am calling a win32 dll using DllImport. Everything works fine in Windows XP. However when i use the same exe and dll in Windows 7, the win32 dll fails to get loaded. Do i need to write any extra code to invoke a win32 dll from Windows 7 ?


回答1:


Before building the C# program, make sure that in Visual studio Configuration Manager you choose "x86" and not "any CPU" as the platform. If any CPU is selected, your C# application runs as a 64bit process in Windows 7 and tries to load the 32-bit win32 dll in to the 64-bit process which would fail as explained here and here.




回答2:


Is your windows 7 64 bit?

Is you .NET exe marked as AnyCPU?

If the answer is yes to the above then you need to mark you .exe as x86 via the Configuration manager in Visual Studio.



来源:https://stackoverflow.com/questions/8131552/how-to-call-win32-dll-in-windows-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!