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去開啓承載進程。而後展開一系列的動做。
好了,看到這裏,也基本能看出個大概了。
有網友但願提供精簡版的安裝包,指望各位能本身動手去完成。