Tech Off Post

Single Post Permalink

View Thread: Static initializers and reflection
  • User profile image
    BitFlipper

    A related question...

    Let's say I'm writing a compiler that takes IL and compiles it to some native code. At runtime, would it be enough to call all static contructors of all classes to ensure that static fields are properly initialized (does order matter?), or is there something else that needs to be executed as well (in addition to the assembly's EntryPoint)?

    So basically:

    1. Call all static constructors
    2. Call Assembly.EntryPoint