¿Es mejor hacer referencia a una DLL o tener soluciones multiproyecto?

I'm still learning .NET (specifically C#), and I'm curious as the advantages of creating and referencing a dll versus having a multi-project solution? I have the opportunity to do either one, but I'm not sure which would be better. The projects that would be dlls are rather small, but will potentially be reused. Should size and reusability be a factor when making this decision? Thanks for any and all help.

preguntado el 31 de julio de 12 a las 14:07

Imo it's usually better to directly link to the project/solution file. This way you have full power of debugging and codechanging at your hand. -

Typically a project produces an assembly (dll or exe) eventually, so your question doesn't quite make sense, since it's possible to have both. However, it's quite common in the .net-world to produce projects/assemblies for the tiniest things, which in my opinion is an antipattern -

It all depends on what your trying to do. Can you give a bit more information about the project requirements. -

Of course if your projects are not in the same folder, you'll have problem using a version control system. -

5 Respuestas

You're still technically referencing other assemblies as each project generates an assembly.

One benefit of having a multi-project solution is that you don't need to build two different solutions- if you change code in both projects the whole solutions builds in one step. Also you can debug both projects at the same time (which is possible with separate solutions, but trickier).

Size may be a factor in build times, but unless they are huge it shouldn't be a huge issue. If projects are used by other solutions it may make sense to keep them in separate solutions so you can control the build process better.

Having separate solutions can also help you keep the interfaces constant since it's moderately harder to change interfaces through the whole stack.

Respondido 31 Jul 12, 14:07

Regarding buildtimes it's worse to have many projects than one big (depending on build configuration, of course) - Daniel

@Daniel I was thinking more if you continually rebuild a large project that doesn't change, but your point is valid. - stanley

Each project will still output it's own assembly, but grouping projects does make debugging and building easier.

If you are confident that you can reuse the individual projects in the future, start with a multi project solution. Design your projects carefully to minimize interdependence. If you do a good job of this, it shouldn't be too hard to separate them at a later date when you decide you want to develop an individual project independently from the whole solution.

Respondido 31 Jul 12, 14:07

If the assemblies aren't going to be shared amongst other projects I'd just have them in the same solution.

If the code is shared between projects that's different. I tend to treat code which is shared between projects the same way as any other third party binary - that is, I take a copy of the DLL at a specific version and reference the DLL.

The advantage of that is that, in 6 months or a year down the line when both projects that share the code are on different release schedules, each one has complete control as to when it takes the hit of updating the shared code and dealing with potentially breaking changes.

If you've just built the shared code directly into your project you're at the mercy of changes any other project requires - not a good place to be!

Respondido 31 Jul 12, 14:07

when you are initially developing the consuming programme i find it easiest to have a multi-project solution. but when later you develop another programme that also consumes teh same dll's, just reference tehm.

Respondido 31 Jul 12, 14:07

I would suggest you to add library project and you referencing project in the same solution. You reference the library project using Project reference. That would help you to debug and maintain your code better.

Respondido 31 Jul 12, 14:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.