简体   繁体   中英

.NET Multiple Class Library in One Library

I am working in VS2008. I have a custom class library (CL1) which references another custom class library (CL2). This ends up having CL1 and CL2 in my release folder. Now the consumer of CL1 needs to include two dll's in the project which I think is not appropriate. I have strong feeling that there must be a way to achieve a single DLL solution. Is there a recommended (guideline-d) way of achieving this.

Merging CL1 and CL2 is not an option because CL2 is more common and referenced in multiple other projects/dll's . Am I missing some straight forward option? Or I need to embed CL2 as resource? How? Googled web but could not find the problem discussed anywhere.

Yes you can do it manually before releasing your product using ILmerge. More details can be found here at codeproject and on Brad McCabe's blog.

You could include the source code from CL2 as a linked files in the CL1 project, and use that as a way to avoid requiring the user to include multiple references. In my opinion, this is a bad idea.

If your class design really requires that your classes be split among multiple assemblies, and CL1 needs to refer to CL2, then its perfectly fine for the user to refer to multiple assemblies -- especially since, as you say, the assemblies serve different purposes.

If the user is only using classes from CL1, then they will not need to add multiple assemblies as references. However, if CL1 refers to CL2, CL2 will always be copied along with CL1, even if the reference to CL2 isn't explicit.

Well, you could embed CL2 in CL1 and use the AssemblyResolve event to extract it when needed, by I would really not advice you to go that way. Simply include the DLL in the release, that is the normal way of distributing it, I would say.

I believe this question may give you the answer you're looking for:

How to link a .DLL statically?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM