简体   繁体   English

强制C#64位应用程序以32位运行?

[英]Forcing a C# 64bit application to run as 32bit?

Let's say that when i've compiled a managed assembly, i've forced it to be 64 bit (using the configuration manager). 假设当我编译一个托管程序集时,我将其强制为64位(使用配置管理器)。 and let's say, that after the compilation i want to run that application as a 32bit process. 假设在编译之后,我希望将该应用程序作为32位进程运行。 can i force it to be 32bit again? 我可以强迫它再次变为32位吗? i tried to play around and edit the PEHeader (the Machine and 32BitOnly fields), but the application won't start on a 32bit platform. 我尝试玩耍并编辑PEHeader(“机器”和“ 32BitOnly”字段),但该应用程序无法在32位平台上启动。
is there a difference in the produced IL when i force the compile it as 64bit? 当我强制将其编译为64位时,生成的IL有什么区别? (in comparison to AnyCPU) (与AnyCPU相比)

I don't believe there is a difference in the IL, the difference in the the non-managed headers. 我不认为IL有区别,非托管标头也有区别。 64 bit mode compiles an EXE with a PE32+ format header (that is 64 bit). 64位模式使用PE32 +格式的标头(即64位)编译EXE。 So just changing a flag won't change the actual format of the EXE. 因此,仅更改标志不会更改EXE的实际格式。 That's the reason you get the error that it is not a valid 32bit applications, it's not, it's a 64 bit application and 32 bit Window's can't parse the PE32+ header. 这就是为什么您会得到以下错误的原因:它不是有效的32位应用程序,不是,它是64位应用程序,而32位Window无法解析PE32 +标头。

You would have to completely rewrite the EXE to PE32 format, so it probably isn't possible. 您必须将EXE完全重写为PE32格式,因此可能无法执行。

Can't you just recompile or is this just for your own interest? 您不能只是重新编译还是为了您自己的利益?

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

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