For applications that were written by using the .NET Framework, hosting the common language runtime is completely transparent. If you compile your managed code as an .exe assembly, the runtime is started automatically by mscoree.dll when the .exe is run. However, unmanaged applications can also benefit from hosting the common language runtime. The runtime provides a framework for extending applications such as Microsoft Internet Information Services and Microsoft SQL Server 2005..net
Whether it is invoked automatically, as with managed .exe assemblies, or loaded by using the unmanaged hosting API, a .NET Framework application requires a piece of code called a runtime host. The runtime host loads the runtime into a process, creates application domains within the process, and loads and executes user code within those application domains.prototype
exe 的执行入口,就是那个mscoree.dll 。code
因此 一旦在注册表 +系统目录中注册了这个Dll 那么托管语言的程序就能被加载执行。orm
Runtime Hosts
The common language runtime has been designed to support a variety of different types of applications, from Web server applications to applications with a traditional rich Windows user interface. Each type of application requires a runtime host to start it. The runtime host loads the runtime into a process, creates the application domains within the process, and loads user code into the application domains.server
从这段文字就看出来,虚机程序的奥妙所在。全部的虚机程序,都由运行时承载。
Loading the Common Language Runtime into a Process
Before any managed code can be executed, the host must load and initialize the common language runtime. All hosts start with an unmanaged stub because the runtime is not yet running in the process. The .NET Framework provides a set of unmanaged APIs called the hosting APIs that the host can use to start the runtime. For more information, see Hosting Interfaces.
To load the runtime into a process, a host calls the CorBindToRuntimeEx Function function. The prototype for CorBindToRuntimeEx Function is located in Mscoree.h in the Include directory of the Windows Software Development Kit (SDK). The host uses CorBindToRuntimeEx Function to control which version of the runtime to load and the behavior of basic functions such as garbage collection and assembly loading. A host can set the values listed in the following table.
上述文字来自MSDN :https://msdn.microsoft.com/en-us/library/01918c6x(v=vs.90).aspx
托段代码加载执行前,须要开辟一个指定的进程进行承载。如何去开启运行时承载进行?.net 提供了一系列的非托管接口API,由这些API去开启承载进程。而后展开一系列的动做。
好了,看到这里,也基本能看出个大概了。
有网友但愿提供精简版的安装包,指望各位能本身动手去完成。