【.Net Framework 体积大?】不安装.net framework 也能运行!?原理补充-3

继续补充点吧。接上一篇,我们实现了.net framework的精简的步骤。

有网友评论了,那个核心的 mscoree.dll 

从.net framework 2.0开始,微软开始了新的CLR承载模型。程序域模型。

参考文档:

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

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.

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.

 

exe 的执行入口,就是那个mscoree.dll 。

所以 一旦在注册表 +系统目录中注册了这个Dll 那么托管语言的程序就能被加载执行。

 

 

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.

 

从这段文字就看出来,虚机程序的奥妙所在。所有的虚机程序,都由运行时承载。

 

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去开启承载进程。然后展开一系列的动作。

 

好了,看到这里,也基本能看出个大概了。

有网友希望提供精简版的安装包,期望各位能自己动手去完成。

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值