VS Runtime Compilation Time (.NET)

.NET compilation has two phases

  • 1. Compilation of the IL code.

  • 2. JIT for native code.

Can both of these stages be classified as compilation time? Or is compiling JIT for native code under control?

In terms of error, if the error occurs in the second phase, is it a runtime error? (Any error that occurs after phase 2, i.e. when the native code is actually executed, must be a run-time error)

+6
source share
2 answers

According to my understanding -

Compiling C # to MSIL and compiling MSIL for native code are two stages of the compilation process. Errors that occur at both stages are compile-time errors.

However, it is unlikely that the second stage (JIT) will cause compilation errors. If your C # code compiles correctly in MSIL, it will be JITed to its own code without any problems.

IMO The most important thing that happens during JITing is optimization for its own platform.

Runtime errors are those that occur at runtime of your own JITed code.

+4
source share

The case where JIT compilation may fail is to create dynamic assemblies with System.Reflection.Emit elements.

I would consider this a runtime error, the compile-time error was an error that occurs when the C # compiler detects an error in the code that emits IL.

0
source share

All Articles