Monday, May 18, 2009

System.ServiceModel.EndpointNotFoundException: Could not connect

Problem ( Took 2 days to Solve)

When You try to consume Self-hosted WCf services from Windows From in VS 2008. You might get this error quite often...

System.ServiceModel.EndpointNotFoundException: Could not connect to http://localhost:8731/Design_Time_Addresses/MyCalculatorService/MyCalculatorService/. 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 --->

This error is due to the Behavior of WCF service. You need to make Singleton instance of that WCF Service.
so You need to add following code before start of Service Class in Service file.

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]


and again build service or whole solution and Run the Windows From then You get the answer.

Thank You.

No comments:

Post a Comment