gpt4 book ai didi

c# - 具有多个托管模块的程序集

转载 作者:行者123 更新时间:2023-11-30 12:34:20 24 4
gpt4 key购买 nike

我了解一个程序集由 1 个或多个模块以及资源文件(如果有)组成。

如果您用 C# 编译项目,那么编译器会简单地将代码转换为托管模块,然后将该模块放入程序集中。现在我的问题是,一个程序集什么时候会有超过 1 个托管模块?

最佳答案

这里有一个很好的解释 Netmodule vs. Assembly .

简而言之,出于以下原因,人们会使用多个模块:

Multi-language assemblies.

If the assembly is consist of source files with different programming languages, you have to compile files with the same programming languages into netmodules, then link them into assemblies.

Separately maintained source files.

If the assembly is maintained by multiple developers, it may make sense to separate the source files into small collections. Each collection is owned by an individual developer. Collections are compiled as netmodules, then linked to the final assembly.

Small download footprint.

If the assembly is hosted in an http site, CLR will only download the main module at the first time. The remaining modules will be downloaded on demand. You can separate the less frequently used code from the main line code, and compiled the less frequently used code as a netmodule. User will only download the netmodule when it is needed.

Link the same source files into multiple assemblies.

You may have some common code that is used in multiple assemblies. The common code is small enough that it is not worth to compile them into a separate assembly. To avoid compiling the same source files multiple times, you can compile them into a netmodule, then link it into different assemblies.

关于c# - 具有多个托管模块的程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7415892/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com