This blog is about developing Windows applications using Visual Studio. All postings on this weblog are provided "AS IS" with no warranties, and confer no rights. Use of any samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
Your host Nikola Dudar is a Program Manager in Windows division of Microsoft Corporation. He has been working on Windows Web Services API during Windows 7 and various additions to Visual C++ during VS2005 and VS2008. More details are in LinkedIn profile under Nikola's formal name Mykola Dudar.
If you are interested in program management and project management, check out my other blog at http://www.pmsnack.com/ where I collect best practices and other topics interesting to program and project managers.
To send feedback, comments or requests for new posts, please use the contact form.
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:
where pathToClient.exe is the path to the EXE of your client that you have just built. In my case I replaced it with a full path to WcfServiceClient.exe in bin\Debug folder of the project.
You may choose any way to solve this error you'd like.
Here's yet another 'Ctrl+F5' option:
1. In Solution Explorer, highlight the solution (assuming the solution is showing)
2. Right Click and select 'Set Startup Projects'
3. Select 'Multiple startup projects'
4. Change 'Action' for the Client and the Service to 'Start'
5. Highlight the service class then use up/down on the right side to move the service class to be before the client class
6. Click OK
7. Launch app via Ctrl+F5
Nikola - thanks much for taking the time and effort to do this (and your other) posts.
Thanks, Nikola and John H. I'm just starting to learn WCF and couldn't make the first example in the book work! This post helped me make it work. Thanks again.
Hello I have 6 projects in my Solutions. and I have done same as JohnH suggest but not able to solve my problem.