我在msdn 找到相关描述:
If your application uses 32-bit components, make sure that it always runs as a 32-bit application.If the Platform target property for your application project is set to AnyCPU, the compiled application can be run in either 64-bit or 32-bit mode. When it runs as a 64-bit application, the just-in-time (JIT) compiler produces 64-bit native code. If the application depends on a 32-bit managed or unmanaged component, that component will fail to load in 64-bit mode. To correct this problem, set the project's Platform target property to x86 and recompile. 关键是他娘的,我换成 x86 编译,又报找不到这个DLL文件,不能加载。这个DLL 无论扔那个环境目录下都这样。

解决方案 »

  1.   

    有的32位程序是不兼容64位平台的。如果兼容的话,你也编译成32位程序。
    如果你需要大内存支持,那么可以试试写一个32位程序调用dll并公开为服务,然后这个64位程序通过进程通讯方式调用这个服务。
      

  2.   

    32位上跑肯定没有问题?直接看看dllimport里面的源码,看看怎么着DLL的咯
      

  3.   


    哪里看得到源码哟。要是能拿到源码,我直接叫人封成托管dll 了。哪有这么抓狂呀
      

  4.   

    如果这个dll兼容64位平台,你只需要把自己的程序也编译成32位即可。
    否则必须使用一个32位系统,即使是虚拟机。
      

  5.   


    哪里看得到源码哟。要是能拿到源码,我直接叫人封成托管dll 了。哪有这么抓狂呀我说的是DLLImport的源码。
    算了,你还是确定那个dll能在64位上用才捉狂吧
      

  6.   

    如果DLL编译时是X86,哪么在64位系统上运行肯定有问题
      

  7.   

    我重装了系统,换成32 位 win7 了。 问题依旧,现在把编译目标无论怎么切换,它都报 找不到这个dll 了
    Unable to load DLL 'C:\\DRIVERS\\CDM8240\\GRGCDMDevDll.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}
      

  8.   

    看看这个 DLL 的依赖项 !
    要求这个 DLL 的依赖项在 LoadLibrary 的要求路径中。
      

  9.   

    32 位的 DLL 一定使用 x86 的模式编译。
    这个不需要其他的尝试。
      

  10.   

    问题已经解决了,多谢各位兄弟。
    这个原因是:原厂提供的DLL本身有问题。 唉,真坑爹啊。