Visual Studio: Simultaneously develop WCF client and server
I need to develop a WCF server (basically a web service which will eventually run in IIS) and a client application that accesses the service. I have both the client and the server project in the same Visual Studio (2008) solution.
What's the recommended way to connect the client to the server during development?
Two possible solutions immediately come to my mind: One is to deploy the server project to some IIS after every change, and the other one is to start two instances of Visual Studio and use a fixed TCP port for the (Visual-Studio-integrated) web server of the server project.
Since none of these options seems particularly elegant to me, I was wondering if I have maybe overlooked the obvious "right way" to do this...
The way I do is like this: - Right-click on your solution file, and choose Set Startup Projects... - Choose Multiple startup projects and choose Start for your client and server project, leave the other ones set to none.
Now both projects will run at startup, and you will be able to debug them both.
Because i have a lot of WCF services used by my project and i do not want to have to run too many instances of VS for debugging, this is what i do:-
If you are ok with having a local IIS, you could consider this.
For each WCF Service, i have created a Web Site project.
This website projects are also shared as Web Folders in local IIS. eg http:\mylocalmachine\WCFService1\servicefile.svc
In my WCF clients web.config, the URL for the service is specified as above. eg (http:\mylocalmachine\WCFService1\servicefile.svc)
Since i dont want to deploy manually every time i change the service, in the post build of each WCF Service project, i have a postbuild task that copies the contents of the bin directory to the bin directory of the website for that corresponding WCF service (one time setup for the postbuild)
My folder structure is such that for every service project, there is a service host (website) project at the same level so the postbuild is very straightforward as well.
When i run my WCF client (F5), the service projects are compiled, their contents are copied to the websites bin (i.e. automatically deployed to IIS) and i can debug any service just by stepping into the code as my services are in the same solution as my WCF client
An added advantage of this approach is that my debugging (atleast of the services) is also using IIS similar to what my production setup will be like.
Edit : I dont put the service host projects (websites) in my solution as otherwise when running my WCF client, VS opens up a cassini instance for each of them, which is irritating and i anyways dont need or use