Multiple applications in single solution

Neo picture Neo · Jan 23, 2012 · Viewed 7k times · Source

I believe this is possible but unsure how to go around it, I need to create a server/client solution, normally I would create a new solution for the server and a new one for the client however I am looking to do this within a single solution as they would both be using the same custom classes and don't really want the issue of having to change the same file twice.

So the question is can I create multiple exe's within a single solution and what are the steps to achieve this.

I have searched on here but don't fully understand the procedure so if someone can point me in the general right direction it would be great. :)

VS2010 using C Sharp and Windows Forms

Answer

Dr. Andrew Burnett-Thompson picture Dr. Andrew Burnett-Thompson · Jan 23, 2012

Please see this and this previous answer which I gave on cross-platform client server application development, specifically with code-reuse across multiple clients. This is also applicable to your Winforms client server app here.

As many answers are saying, you can structure your solution in order to share code as follows:

Project Structure

Solution
.. Common (Messages, Datacontracts, Utilities)
.. Middleware (References Common, provides common services)
.. .. Server Exe (References Common, Middleware)
.. .. Client Exe (References Common, Middleware)

Top level client-server architecture

Cross-platform application stack

Your stack becomes

Clients:

Client has serialization, client side implementations of webservices/middleware and Model-View-Presenter patterns for the view.

Middleware:

Middleware, i.e. shared services and data transport implemetation on server / client desktop can be the same. Alternatively you could call this Services. Any specific services for client only (or server only) should go in separate assemblies and referenced only by the specific exe (client or server). i.e. dont share code that isn't shared!

Messages/DataContracts:

Shared across all clients/server using the techniques I outlined above. In your case these may be common domain objects shared between client and server

Server:

All business logic, DB access and server-side service implementations. For DB Access I'd recommend PetaPoco as an excellent MicroORM.

Development and debugging

Yes, a solution can have more than one exe, simply use set Startup Project by right clicking on Server Exe or Client Exe to debug one or the other.

If you wish to run the client and server together, you can run both from the command line and attach the debugger to both processes.

Best regards,