Question

I am using Visual Studio 2010 and I am trying to create a solution containing an N tier architecture.

I have a project each for every tier

  • Common
  • DAL
  • Business //
  • Service // WCF
  • ServiceHost
  • Web

the projects are listed above are also called in the same order as well; so Web talks to Service tier, service tier talks to Business and business then talks to factory and factory project is responsible for talking to DB.

the issue I am having is to setup my projects in a way that before Web project is launched by pressing F5 - ServiceHost (which is just a self host console for WCF) should be started first so when Web calls for a service; it is up and running already.

Note: in PRD; Web and WCF will be hosted on different boxes altogether so this wont be an issue but for developing on Local machine - I need the above.

Interim Solution - I have excluded ServiceHost Project from the solution so it doesnt get launched with Web and I am running the ServiceHost executable externally from command line to get the Service up and running and then I am launching the Web project as normal using F5.

Can someone please tell me what do I have to do to achieve the above?

Was it helpful?

Solution

As Rajesh suggested, you set multiple projects to start in a multi-project solution. To do this, select DEBUG -> Set Startup Projects (or right-click on the solution and select Set Startup Projects... from the context menu.

This will give you a window that lists all your projects in the solution. Check the "Multiple startup projects" radio button, and set the Action column to "Start" or "Start without debugging" for each project you want to run. You can use the up and down arrows to specify the order.

If your web application requires the service to be available when it starts (i.e., the web site calls the service during it's initialization/startup), you may be better off doing as you are now (running the WCF service from the command line), otherwise this should get you where you want to be.

Attached is a screenshot (VS 2012) with a solution similar to the one you outlined above:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top