So you developed a Silverlight application that gets data from a WCF/asmx web service. All is going great until that point where you test your application and get the one error you didnt want to face: "NotFound"... no information is available, nothing in the innerexception field can give you hints on what just went on and you are practically left alone in the battle... Fear not! Here are a few steps you can take to find out whats wrong:
Step 1: it's 11 o’clock. Do you know where your clientaccesspolicy is?
A very common cause for this error lies within the clientaccesspolicy.xml and crossdomain.xml files.
If your application and service are hosted on different domains, or hosted on the same domain but on different ports (for example: when debugging a solution that consist of a WCF service and Silverlight application) Silverlight considers the call a cross-domain call.
Cross domain calls check for the availability of clientaccesspolicy.xml, crossdomain.xml or both in the root of the web site that hosts the service and whether or not they can be found - a NotFound error will be thrown.
Use Fiddler2 or similar tool to make sure your files are accessed correctly.
Step 2: Sir, are you positive you got the address right?
Another scenario that happened to me quite a few times with this error lies within the "ServiceReferences.ClientConfig" file.
Let's say we are consuming one of SharePoint's web services for a sub site, whose address is: http://thelumberjack/trees/_vti_bin/lists.asmx. After successfully adding the service refrence, take a look at the clientconfig file, you might see that the address http://thelumberjack/_vti_bin/lists.asmx is added instead of the correct address and that can lead to a NotFound error as the list we are querying from simply isn’t there.
Step 3: calling the WCF Service Configuration Editor for help!
Time to bring in the big guns.
The first step should be enabling tracing; To do so, follow these instructions:
1) Right click on the "web.config" file of the WCF Service project and select "Edit WCF Configuration". If you don’t see this option, click Tools and then "WCF Service Configuration Editor", close the editor and then right click the "web.config" file again.
2) Click on "Diagnostics" and set "Tracing" to "On" by clicking on "Enable Tracing". Make sure you set where to save the log file by clicking on "ServiceModelTraceListener" and then browse for the directory of your choice.
3) Run your project and wait for the unavoidable NotFound error to show up.
4) Navigate to the dir you selected earlier to save the log file at and double click the log file. Microsoft Service Trace Viewer will come up. Look for red lines like the one in the picture that would indicate an error:

Once you click on that line and dig deeper, you will find the real error in all his glory next to the Message:

In my case the error is mismatched binding between Silverlight and WCF, and in my next post we will show how to change WCF's binding to the one Silverlight works with in few simple steps.
Thank you for reading and looking forward to see your comments!