What is the life cycle, if any, of a C # executable console application?

I am interested to know if there is any life cycle of a C # console application similar to the ASP.Net life cycle.

I'm particularly interested

  • build resolution - when this happens
  • compilation - how the method static Mainaffects the compilation of dependent objects
+3
source share
1 answer

Typically, each method is executed JITted because it is first executed, and assembly resolution is again performed as needed, which usually means “during the JIT method, which uses the assembly that we don’t need yet” (but can also mean: through reflection).

static Main , ; , Main, Main. ( ):

static int Main(string[] args) {
    try {
        return MainImpl(args);
    } catch(Exception ex) {
        // .. do something
        return -1;
    }
}
[MethodImpl(MethodImplOptions.NoInlining)]
static int MainImpl(string[] args) { ... }

, , Main ( MainImpl), ... catch - Main, Main .

...

  • (Main)
  • , ; exe, " Main ",
+6

All Articles