When you are hosting a WCF service in Visual Studio, a Cassini Web Server will spin up and assign a random port number, e.g. http://localhost:61447/MyService. If you add a Service Reference, it will use that port number currently assigned by Cassini. This is all good until you stop the Cassini Web Server, or restart VS IDE. Where did my old port number go???
The problem I have with this is that it gets meddlesome very quickly. Of course you can host your WCF on IIS on your development machine, but if not there is another option. You can assign a Specific Port Number in your VS project Settings. Right click on your WCF Service Project and select Properties. Click the Web tab on the left, and assign a specific port number of your choice. Problem solved! Just make sure you don’t attempt to host different services on the same port number.
|Share this post:|