[英]VS 2010 Project always targeting x86/32 bit
I have a project that seems to always be targeting x86/32 bit and I can't find out why. 我有一个似乎总是针对x86 / 32位的项目,我不知道为什么。 I have gone through all the projects in solution and made sure the PlatformTarget is AnyCPU.
我已经遍历了解决方案中的所有项目,并确保PlatformTarget是AnyCPU。
Using dumpbin to examine all the binaries I get '14C machine (x86)'. 使用dumpbin检查所有二进制文件,我得到了“ 14C机器(x86)”。
The build machine is x64 although previously was x86. 尽管以前是x86,但是构建机器是x64。
What else could be causing this and what should I check? 还有什么可能导致这种情况,我应该检查什么?
You must be talking about the output you see from Dumpbin.exe with the /headers option. 您必须谈论使用/ headers选项从Dumpbin.exe中看到的输出。 Which looks like this when run on a .NET assembly that's compiled with the platform target set to AnyCPU:
在以平台目标设置为AnyCPU编译的.NET程序集上运行时,其外观如下所示:
Dump of file ConsoleApplication1.exe
PE signature found
File Type: EXECUTABLE IMAGE
FILE HEADER VALUES
14C machine (x86)
3 number of sections
4E3E987F time date stamp Sun Aug 07 08:51:59 2011
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
102 characteristics
Executable
32 bit word machine
etc..
Yes, the IMAGE_FILE_HEADER.Machine value is set to 0x14c, the value of IMAGE_FILE_MACHINE_I386 (aka x86). 是的,IMAGE_FILE_HEADER.Machine值设置为0x14c,即IMAGE_FILE_MACHINE_I386(aka x86)的值。 This is of no consequence, perhaps the strongest hint that it is not relevant is the target name: AnyCPU.
这无关紧要,也许最不相关的最强提示是目标名称:AnyCPU。 It runs as well on an x86 as on an x64 operating system.
它在x86上以及在x64操作系统上都能很好地运行。
What you really want to use is corflags.exe, it shows you the COR header in the file: 您真正想要使用的是corflags.exe,它向您显示文件中的COR标头:
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 1
ILONLY : 1
32BIT : 0
Signed : 0
The 32BIT flag is the important one, 0 indicates that AnyCPU was used. 32BIT标志是重要的标志,0表示已使用AnyCPU。 ILONLY = 1 indicates that the assembly contains IL only, no machine code.
ILONLY = 1表示程序集仅包含IL,不包含任何机器代码。 It will be 0 when you create assemblies with the C++/CLI language.
使用C ++ / CLI语言创建程序集时,该值为0。
You can create an image file with the machine set to x64. 您可以在机器设置为x64的情况下创建图像文件。 I think that was introduced in .NET 3.0 (aka .NET 2.0 SP1).
我认为这是在.NET 3.0(又名.NET 2.0 SP1)中引入的。 If you set the platform target to x64 then the machine type field will be set to IMAGE_FILE_MACHINE_AMD64 (aka x64).
如果将平台目标设置为x64,则计算机类型字段将设置为IMAGE_FILE_MACHINE_AMD64(aka x64)。 That doesn't make much difference, other than that the program will never run on a 32-bit operating system and that the main thread will get started with a 4 megabyte stack instead of a 1 MB stack.
除了程序永远不会在32位操作系统上运行以及主线程将以4兆字节堆栈(而不是1 MB堆栈)启动之外,这没有太大区别。
The magic that turns a 32-bit executable image into a 64-bit process is described in this answer . 该答案描述了将32位可执行映像转换为64位进程的魔术。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.