amrahs
amrahs

Reputation: 49

.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.

Upvotes: 2

Views: 4306

Answers (4)

TheVillageIdiot
TheVillageIdiot

Reputation: 40497

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.

Upvotes: 4

richardtallent
richardtallent

Reputation: 35363

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

How to link a .DLL statically?

Upvotes: 0

Nader Shirazie
Nader Shirazie

Reputation: 10776

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.

Upvotes: 1

Fredrik Mörk
Fredrik Mörk

Reputation: 158289

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.

Upvotes: 0

Related Questions