Grouping classes in an assembly
This useful bit of information crossed my desk today:
When it comes to packaging in separate assemblies, remember that you pay a fairly large performance hit on an assembly load. An assembly should really be considered a unit of security control, independent versioning, or contribution from disparate sources. You might consider placing code in a separate assembly if it is used extremely rarely, but probably not.
Here are some pointers from the "Designing .Net Class Libraries" course:
Factor functionality into assemblies based on:
- Performance - There is overhead in loading each assembly. All other things being equal, the fewer assemblies an application loads, the quicker the load time.
- Versioning - All code in an assembly must version at the same rate.
- Security - All code in an assembly has the same identity and is granted the same level of trust.
Assemblies and Performance
- Prefer single, large assemblies to multiple, smaller assemblies
- Helps reduce working set of application
- Large assemblies are easier for NGEN to optimize (better image layout, etc)
- If you have several assemblies that are always loaded together, combine into a single assembly.
Comments
- Anonymous
June 24, 2004
Fine, but is there a way to have multiple Vs projects produce a single assembly? - Anonymous
June 24, 2004
Are there design-time advantages to breaking things up into multiple assemblies? E.g. IDE only needs to recompile code in the one small assembly that you've changed. Although with the good speed of the C# compiler, I'm not sure how much difference this would make in reality...
Also, as Barry wrote, there are advantages in using multiple assemblies when it comes to enforcing discipline about which layers can access which other layers.
I guess one option is to use "many" "small" assemblies at design time. Then, if you are using a build process (such as Ant) which is independent of the IDE's project structure, you can compile the release version of your system into relatively few "large" assemblies. - Anonymous
June 24, 2004
The comment has been removed - Anonymous
June 24, 2004
The comment has been removed - Anonymous
June 24, 2004
The comment has been removed - Anonymous
June 24, 2004
The comment has been removed - Anonymous
June 24, 2004
I have some comments on how to combine both Eric's performance requirements of larger fewer assemblies with the smaller more assemblies at design time to enforce layering rules.
Yes you can compile multiple projects together into a single assembly.
http://objectsharp.com/Blogs/barry/archive/2004/06/24/693.aspx - Anonymous
June 25, 2004
Sometimes, I don't know how to combine all of them together. For example, a UI Control which contains a MS Web Browser. It needs some ActiveX Interop dlls. Also, when you just got some assemblies from the Internet without the source projects. How can we combine them into a LARGE assembly? Does anyone know? :-) When the outside world doesn't use the assembly directly, it is always good to pack them inside the assembly which uses it. - Anonymous
June 27, 2004
Does the "large performance hit on an assembly load" happen just once at when the assembly is first used? Under what circumstances are assemblies unloaded / reloaded? Just how large is the "large performance hit?" - Anonymous
July 11, 2004
The comment has been removed - Anonymous
August 09, 2004
Is there a way that I can incorporate a compiled assembly into my main project.
My project uses only one 3rd party DLL and I would like to have only 1 final DLL instead of 2. - Anonymous
December 27, 2004
[http://itpeixun.51.net/][http://aissl.51.net/][http://kukuxz003.freewebpage.org/][http://kukuxz001.51.net/][http://kukuxz003.51.net/][http://kukuxz005.51.net/][http://kukuxz002.51.net/][http://kukuxz004.freewebpage.org/][http://kukuxz007.51.net/][http://kukuxz001.freewebpage.org/][http://kukuxz006.51.net/][http://kukuxz002.freewebpage.org/][http://kukuxz004.51.net/][http://kukuxz008.51.net/][http://kukuxz009.51.net/][http://kukuxz005.freewebpage.org/][http://kukuxz006.freewebpage.org/][http://kukuxz007.freewebpage.org/][http://kukuxz009.freewebpage.org/] - Anonymous
October 14, 2006
The comment has been removed - Anonymous
June 09, 2009
PingBack from http://greenteafatburner.info/story.php?id=5798