简体   繁体   English

VS 2010项目始终以x86 / 32位为目标

[英]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.

相关问题 在构建64位窗口操作系统时,针对x86与AnyCPU - Targeting x86 vs AnyCPU when building for 64 bit window OSes 从同一VS2012项目中定位x86和x64程序集; 引用 - Targeting x86 & x64 assemblies from the same VS2012 project; references x86目标未在32位Windows XP上运行 - x86 target not running on 32 bit Windows XP 当exe在64位计算机上为x86(32bit)时,dll是否将以32位或64位加载? - Will dll be loaded as 32bit or 64bit when exe is x86(32bit) on a 64bit machine? 面向“ AMD64”的“ Oracle.DataAccess.dll”与项目的目标平台“ x86”不兼容 - 'Oracle.DataAccess.dll' targeting 'AMD64' is not compatible with the project's target platform 'x86' 如何通过反射将一个程序集设置为32位(即x86) - How, with reflection, can I set an assembly to be 32-bit (i.e. x86) 可在32位(x86)和64位(x64)平台上运行的自定义Windows窗体控件 - Custom windows form controls that could run on both 32bit (x86) and 64bit (x64) platform .NET,“任何 CPU/64 位 (x64)/32 位 (x86)”最佳实践、提示和技巧 - .NET, "Any CPU/64Bit (x64)/32Bit (x86)" Best Practices, Tips and Tricks 创建msi软件包时,以“ AMD64”为目标的Oracle.DataAccess.dll与项目的目标平台“ x86”不兼容 - Oracle.DataAccess.dll' targeting 'AMD64' is not compatible with the project's target platform 'x86' when creating a msi package 以x86为目标时,为什么我的项目无法重建,单元测试中的引用没有更新? - Why does my project not get rebuilt and references in my unit tests not get updated when targeting x86?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM