简体   繁体   English

使用x86程序集编译到x64时的内存使用情况

[英]Memory usage when compiling to x64 with x86 assemblies

How does the .net framework behave, if my application is a 64-Bit application (on a 64-bit windows server) but mixes x86 and x64 assemblies? 如果我的应用程序是64位应用程序(在64位Windows服务器上)但混合了x86和x64程序集,则.net框架的行为如何? Does it run as a full 64-Bit app? 它可以作为完整的64位应用程序运行吗? As far as i know does x64 and x86 differ in memory addressing and cpu instruction set. 据我所知x64和x86在内存寻址和cpu指令集方面有所不同。

Now the question, how does memory addressing works if mixing x64 and x86 assemblies and am i able to use more then 2GB ram in an x64 based application using not only x64 compiled assemblies? 现在的问题是,如果混合使用x64和x86程序集,内存寻址将如何工作?我是否能够在不仅使用x64编译程序集的基于x64的应用程序中使用2GB以上的RAM?

Please comment if the question is unclear or if you need further information. 如果问题不清楚或您需要更多信息,请发表评论。

Thank you! 谢谢!

A Windows process can be 32 bit or 64 bit, it's determined by first assembly (your executable file) loaded. Windows进程可以是32位或64位,由加载的第一个程序集(您的可执行文件)确定。 If it's AnyCPU then it'll be 64 bit on 64 bit systems and 32 bit on 32 bit systems (I omit Favor 32 bit for simplicity but you may safely consider that flag as an alias for x86, see also What is the purpose of the “Prefer 32-bit” ). 如果是AnyCPU那么这将是64位在64位系统和32个系统的32位(我省略青睐32位的简单,而且可以安全地认为,标志为86的别名,也见有什么的目的“首选32位” )。

Now the question, how does memory addressing works if mixing x64 and x86 assemblies and am i able to use more then 2GB ram in an x64 based application using not only x64 compiled assemblies? 现在的问题是,如果混合使用x64和x86程序集,内存寻址将如何工作?我是否能够在不仅使用x64编译程序集的基于x64的应用程序中使用2GB以上的RAM?

A 64 bit process cannot load a 32 bit assembly so your question simply doesn't apply. 64位进程无法加载32位程序集,因此您的问题根本不适用。 If you try to load a 32 bit assembly you'll have a BadImageFormatException , that's all. 如果您尝试加载32位程序集,则将具有BadImageFormatException

Moreover when you try to build you solution (mixing AnyCPU with x86 and x64) you also get a specific warning MSB3270. 此外,当您尝试构建解决方案(将AnyCPU与x86和x64混合使用)时,还会收到特定的警告MSB3270。

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

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