使用非托管dll托管AnyCPU [英] Managed AnyCPU with unmanaged dll

查看:157
本文介绍了使用非托管dll托管AnyCPU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.我到处都读到AnyCPU相应地运行着一个运行平台.那为什么不能为托管程序设置AnyCPU,而对于本机dll则说x64呢?我希望它会根据我的笔记本电脑平台运行,但是我有BadImageFormat 当我的程序从该dll调用函数时出现异常,尽管该dll和我的笔记本电脑均为x64.为什么呢?

Hello. I read everywhere that AnyCPU runs accordingly a platform on which it's running. Then why can't I set AnyCPU for managed program and let's say x64 for native dll? I expect that it will run according to my laptop platform but instead I have BadImageFormat exception when my program calls a function form this dll, despite the fact that this dll and my laptop both x64. Why is that?

推荐答案

AnyCPU允许将其加载到32或64位进程中,但不保证该进程将具有任何特定的位数.即使用于启动该进程的exe是AnyCPU,也可能将其标记为首选32位". (我相信那是 在当前版本的Visual Studio中为默认值.)

AnyCPU allows it to be loaded into a 32 or 64 bit process, but does not guarantee that the process will be any particular bitness. Even if the exe used to launch the process is AnyCPU, it might be flagged as "Prefer 32-bit" (I believe that's the default in current versions of visual studio.)


这篇关于使用非托管dll托管AnyCPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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