单个DLL V多个DLL [英] Single DLL V multiple DLLs

查看:111
本文介绍了单个DLL V多个DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前段时间,我漫步在这里问了一个问题,是否最好将大型项目(.NET类库)拆分为多个.NET DLL。建议是使用一个大DLL。

I asked a question on here some time ago when I wandered if it was better to split a large project (.NET class library) into multiple .NET DLLs. The advice was to have one large DLL.

此DLL现在已在另一个项目中使用。另一个项目仅使用几个类,因此项目中有许多未使用的类。

This DLL is now used in another project. The other project only uses a few classes and therefore there are lots of classes in the project that are unused.

从架构的角度来看,这是一个不好的做法,是拥有一个DLL还是我是否在考虑这个问题?

Is this bad practice from an architectural perspective to have one DLL or am I over thinking this?

推荐答案

使用单独的dll有一些利弊:-

There are certain pros and cons for having the seperate dlls:-

缺点:-

性能和复杂性可能会增加。

The performance and complexity may increase.

优点:-

代码重用和层组织

您可能还想检查 关于好的设计的文章 (前五篇是关于SOLID原理的,其余的是关于如何构造dll的)

You may also be interested to check articles on good design (The starting five is about SOLID principles. The rest is about how to structure your dll's)

编辑:-

您将有兴趣阅读此 MSDN :-

You will be intersted to read this MSDN:-


更喜欢单个大型程序集,而不是多个小型程序集

为了帮助减少应用程序的工作集,您应该
单个较大的程序集,而不是多个较小的程序集。如果
有多个总装在一起的程序集,则
应该将它们组合在一起并创建一个程序集。

To help reduce your application's working set, you should prefer single larger assemblies rather than multiple smaller assemblies. If you have several assemblies that are always loaded together, you should combine them and create a single assembly.

与多个较小的程序集相关的开销可能是
的原因如下:

The overhead associated with having multiple smaller assemblies can be attributed to the following:

•加载较小程序集的元数据的成本。

•The cost of loading metadata for smaller assemblies.

•触摸预编译中的各种内存页面CLR中的图像,以便
加载程序集(如果已用Ngen.exe预编译)。

•Touching various memory pages in pre-compiled images in the CLR in order to load the assembly (if it is precompiled with Ngen.exe).

•JIT编译时间。

•安全检查。因为您只为
程序访问的内存页面付费,所以较大的程序集为Native Image Generator
实用程序(Ngen.exe)提供了更大的机会来优化它生成的本机映像
。更好的图像布局意味着可以更密集地布置必要的数据
,这反过来意味着与在多个
中布置的相同代码相比,完成该工作所需的整体页面
更少

•Security checks. Because you pay for only the memory pages your program accesses, larger assemblies provide the Native Image Generator utility (Ngen.exe) with a greater chance to optimize the native image it produces. Better layout of the image means that necessary data can be laid out more densely, which in turn means fewer overall pages are needed to do the job compared to the same code laid out in multiple assemblies.

有时,您无法避免拆分程序集。例如,由于
的版本控制和部署原因。如果需要单独交付
类型,则可能需要单独的程序集。

Sometimes you cannot avoid splitting assemblies; for example, for versioning and deployment reasons. If you need to ship types separately, you may need separate assemblies.

注意:-

.Net DLL是程序集,但事实并非如此。

.Net DLL's are assemblies but the reverse is not true.

这篇关于单个DLL V多个DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆