简体   繁体   中英

Effects of /platform switch on C# assembly in x64 windows

I am reading C# vial CLR and in the first chapter it is mentioned that when the /platform switch is set to anycpu then the .NET Application will be run as a 32 bit application in x86 windows and as a 64 bit application on x64 windows.

What does this exactly mean? How can the application run as a 64 bit application in the x64 windows? The IL Code will be the same since i have set the switch to anycpu.

Will the compilation of IL code into native code change when the application is launched in x64 windows?

Pardon me if this is a fundamental question.

This is achieved by the .Net runtime doing the actual compilation of the code just before it executes it for the first time . Prior to that the "code" is held in a partially compiled intermediate state called Common Intermediate Language (CIL, commonly shortened to just 'IL'). It's "common" because all the .Net languages compile to it, and it's an intermediate language much like Java byte code is.

For more info check out Understanding .NET Just-In-Time Compilation and .NET Compilation - Part 1: Just-In-Time Compiler .

You're correct: at runtime the framework compiles the IL into executable code. IL itself is not executable. A .NET exe file contains very little executable code; just some code which loads or attaches to the framework runtime and then basically says 'Here I am, runtime, compile and run my IL stuff'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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