Monday, February 18, 2008 1:09 PM
NikolaD
WCF in VS2008 – Hosting is required for Ctrl+F5
Here is another interesting feature of VS2008 about which I could not find any documentation about on MSDN. If we go back to the example from my last post, debugging (F5) the WCF Service Client project is going to start WCF Host Service. However running the same WCF Service client program (Ctrl+F5) is going to result in error:
Unhandled Exception: System.ServiceModel.EndpointNotFoundException: Could not connect to http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary/Service1/.
TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8731.
---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:8731
I have to admit that the reason for the error was immediately obvious to me. But if I put myself in shoes of someone who is new to VS or web services, I hardly see how she is expected to figure out the next step from this cryptic error message. And because of a general nature of the error it is easy to get off track if follow discussions of this error on MSDN forum or on other sites.
So what is the root cause for the error? The answer is simple – the service is not running. Client attempts to establish connection to the address of the service on the localhost and it fails to do so because service listener is not running. And this is why it is a TCP error, which reminds us that HTTP is built on top of TCP and it relies on TCP to establish connection to the address.
Now that we establish the root cause for the error, how can one fix it? There are several ways to get Ctrl+F5 running:
You may choose any way to solve this error you'd like.