.NET'任何CPU'目标Winform EXE在*某些* Vista x64计算机上运行为32位 [英] .NET 'Any CPU' targeted Winform EXE runs as 32-bit on *some* Vista x64 computers

查看:75
本文介绍了.NET'任何CPU'目标Winform EXE在*某些* Vista x64计算机上运行为32位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在特定的Vista Business x64计算机上运行.NET应用程序时遇到一个非常奇怪的问题。这个操作系统大约3个月前安装在硬件上(它不是虚拟机),安装了Visual Studio 2008,Office 2007和MS SQL Server。

There is a very strange problem I am encountering regarding running .NET apps on a particular Vista Business x64 machine. This OS was installed on the hardware (it is not a virtual machine) about 3 months ago and has Visual Studio 2008, Office 2007 and MS SQL Server installed.

我创建了一个在Visual Studio 2008中Winforms EXE并且目标"任何CPU" - 我希望此EXE在Vista x64中作为64位进程运行。但是当我在我的Vista x64机器上运行这个程序时,该程序显示为32位进程。

I created a Winforms EXE in Visual Studio 2008 and targeted "Any CPU" - I expect this EXE to run as a 64-bit process in Vista x64. However when I run this program on my Vista x64 machine the program shows up as a 32-bit process.

我也编译了同一个程序,目标是x64(而不是'任何CPU')并且确实在同一台计算机上以64位进程运行。

I also compiled this same program as targeting x64 (rather than 'Any CPU' ) and it does indeed run as a 64-bit process on the same machine.

检查下面的Process Explorer屏幕截图 WindowsFormApplication1ANYCPU.exe (任何CPU目标)和 WindowsFormApplication1x64.exe (x64目标)。

Examine the Process Explorer screenshot below for WindowsFormApplication1ANYCPU.exe (ANY CPU targeted) and WindowsFormApplication1x64.exe (x64-targeted).

我通过检查32验证了这一点Process Explorer的-bit / 64-bit列,同时观察正在加载的.NET框架DLL(用于任何CPU 32位进程的SysWow64,用于x64目标版本的System32)

I verified this by examining the 32-bit/64-bit column of Process Explorer, along with observing the .NET framework DLLs which are being loaded (SysWow64 for the ANY CPU 32-bit process, System32 for the x64-targeted version)

现在,在有人建议第三方DLL或其他依赖项导致此行为的可能性之前,我应该提一下,这个EXE是一个由Visual Studio 2008创建的空的新Winform EXE项目。所以没有pos影响这一点的圣经依赖。我还观察到,像 Paint.NET 这样的.NET应用程序最终会在这台特定的机器上以32位运行,而它应该以64位运行。

Now, before someone suggests the possibility of 3rd party DLLs or other dependencies causing this behavior, I should mention that this EXE is an empty new Winform EXE project created by Visual Studio 2008. So there are no possible dependencies affecting this. I also observe that .NET applications like Paint.NET end up running as 32-bit on this particular machine, when it should be running as 64-bit.

我可以使用相同的可执行文件(目标为"任何CPU "),并在另一台Vista x64计算机上运行它,它作为64位程序运行。因此,似乎我的操作系统有一些特殊之处导致它以32位运行"任何CPU ".NET应用程序。 Windows中的某个设置是否可能导致此问题?与我的同事交谈,他们也在某些计算机上遇到过这种行为,并通过编译他们的应用程序的x86和x64目标版本并让他们的安装程序安装正确的版本来解决这个问题。

I can take this same executable (the one targeted 'Any CPU ') and run it on another Vista x64 computer, and it runs as a 64-bit program. So it seems like there is something peculiar about my OS that is causing it to run 'ANY CPU ' .NET apps as 32-bit. Is there a setting somewhere in Windows that could be causing this? Talking to my colleagues, they have also encountered this behavior on certain computers and have worked around it by compiling x86- and x64-targeted version of their app and letting their installer install the correct version.

显然这会导致严重的问题,例如,如果您链​​接到64位DLL,并且您希望您的代码在x64上以64位运行,但无论出于何种原因,它最终都以32位模式运行。

Obviously this can cause serious issues if for example you are linking to a 64-bit DLL and you are expecting your code to run as 64-bit on x64, but for whatever reason it ends up running in 32-bit mode.

我使用的示例项目是这里(尽管因为它只是一个默认的Visual Studio空项目,没什么可看的)

The sample project I used is here (although since it is just a default Visual Studio empty project there is not much to see)

另外,我用 C:\Program Files \ MicroSoft SDKs启用了Fusion日志记录\ Windows \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ />

Also, I turned on Fusion logging with  C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\FUSLOGVW.exe but saw no interesting information.

推荐答案

很奇怪,第一次我'听说过这个。在.exe上运行Corflags.exe实用程序以仔细检查32BIT标志确实已关闭。请注意,如果更改平台目标设置,则必须执行 调试和发布配置。
Pretty strange, first time I've heard of this.  Run the Corflags.exe utility on the .exe to double-check that the 32BIT flag is indeed off.  Beware that if you change the Platform Target setting, you have to do so for both the Debug and the Release configuration.


这篇关于.NET'任何CPU'目标Winform EXE在*某些* Vista x64计算机上运行为32位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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