Thursday, October 14, 2010

Check list for "Remote Server NotFound" Error with WCF service

Countless people have seen the "remote server not found" error with their Silverlight/WCF application after the application is deployed to IIS.

The most likely cause of this error is that the Service URL is not set right. First thing to check is the ServiceReferences.ClientConfig file.

When you add the service reference under Visual Studio, the Service URL is point to the URL under the Dev Server. It is something like "http://localhost:[PORTNUMBER]/YourService.svc.  This URL certainly won't work when the application is finally deployed to IIS.  You need to change that URL to point to the service under IIS. 
The best way to make the ServiceReference file work in both development and production is to change the service URL to a relative URL:

<endpoint address="http://localhost:[PORTNUMBER]/YourService.svc" .../>
<endpoint address="../YourService.svc" .../>

If you are sure this is not your problem, the next step is to check if you can access your service by simply typing the service URL to a browser. If you see some kind of error message other than of 404 "NotFound" error, the error message usually can give you some kind of information.

One common problem you might find using this method is that the WCF feature is not turned on for IIS7. If this is the case, you need to turn on Windows feature "WCF HTTP Activation" under Control Panel\Programs\Turn Windows features on or off\Microsoft.NET Framework 3.0.