【.Net Framework 體積大?】不安裝.net framework 也能運行!?原理補充-3

繼續補充點吧。接上一篇,咱們實現了.net framework的精簡的步驟。app

有網友評論了,那個核心的 mscoree.dll dom

從.net framework 2.0開始,微軟開始了新的CLR承載模型。程序域模型。ide

參考文檔:ui

https://msdn.microsoft.com/en-us/library/9x0wh2z3(v=vs.90).aspxspa

Hosting the Common Language Runtime

.NET Framework 3.5
 
 

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

 

 

This documentation is archived and is not being maintained.

Runtime Hosts

.NET Framework 3.5
 

 

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

.NET Framework 3.5
 

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去開啓承載進程。而後展開一系列的動做。

 

好了,看到這裏,也基本能看出個大概了。

有網友但願提供精簡版的安裝包,指望各位能本身動手去完成。

相關文章
相關標籤/搜索