Udostępnij za pośrednictwem


Running Code 

The common language runtime provides the infrastructure that enables managed execution to take place as well as a variety of services that can be used during execution. Before a method can be run, it must be compiled to processor-specific code. Each method for which Microsoft intermediate language (MSIL) has been generated is just-in-time-compiled (JIT-compiled) when it is called for the first time, and then run. The next time the method is run, the existing JIT-compiled native code is run. The process of JIT-compiling and then executing the code is repeated until execution is complete.

During execution, managed code receives services such as garbage collection, security, interoperability with unmanaged code, cross-language debugging support, and enhanced deployment and versioning support.

In Microsoft Windows XP, the operating system loader checks for managed modules by examining a bit in the common object file format (COFF) header. The bit being set denotes a managed module. If the loader detects managed modules, it loads mscoree.dll, and _CorValidateImage and _CorImageUnloading notify the loader when the managed module images are loaded and unloaded. _CorValidateImage performs the following actions:

  1. Ensures that the code is valid managed code.

  2. Changes the entry point in the image to an entry point in the runtime.

On 64-bit Windows, _CorValidateImage modifies the image that is in memory by transforming it from PE32 to PE32+ format.

See Also

Concepts

Managed Execution Process

Other Resources

Security in the .NET Framework
Interoperating with Unmanaged Code
Deploying .NET Framework Applications