rjv
rjv

Reputation: 61

Run time VS Compile time (.NET)

.NET compilation has two phases

Can both these stages can be categorized as compile time? Or does the JIT compilation to native code comes under runtime ?

In terms of error, if an error occurs at the phase two, is it a run time error? (Any error that occurs after the phase 2 ie, when the native code is actually executed should be a run time error )

Upvotes: 6

Views: 1013

Answers (2)

vc 74
vc 74

Reputation: 38179

A case in which the JIT compilation could fail is when building dynamic assemblies with System.Reflection.Emit members.

I'd consider it a runtime error, a compile time error being an error raised when the C# compiler detects an error in the code that emits the IL.

Upvotes: 0

Unmesh Kondolikar
Unmesh Kondolikar

Reputation: 9312

As per my understanding -

Compiling C# to MSIL and compiling MSIL to native code are two stages of the compilation process. Errors occurring in both stages are compile time errors.

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

IMO the most important thing that happens during JITing is optimizations for the native platform.

Run-time errors are those which happen during executing your JITed native code.

Upvotes: 4

Related Questions