سؤال

You can use NGEN.EXE to compile a MSIL assembly to a native assembly. But when you have the source code, you can also choose "Platform target" in the project options. If I choose, say, x64 there, will that be the same thing as running NGEN.EXE on it on an x64 machine?

هل كانت مفيدة؟

المحلول

No, it is not the same thing. Platform target only sets a bit in the PE header, telling the runtime if it prefers to run on the x86 or x64 version of the CLR (or neutral, if you specify "Any CPU"). Compilation will still produce MSIL code; AFAIK, it is not possible to tell to the MS compilers to directly emit native code (for now).

The flag is useful, for example, when you are PInvoking native DLLs for which you have only the x86 version.

In fact, you can also modify this bit later, using CorFlags

NGEN instead will compiler the IL to assembly code (native). It is called also AOT (Ahead Of Time) compilation, as opposed to JIT (Just In Time)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top