Has this type of thing ever happened to you? Sometimes its best to put the keyboard down and walk away from the computer. Last night I was reminded of this when I was writing some code examples for my Silverlight book and struggling with a problem with my WCF service. The problem was that it worked.
No, I am not crazy (well not completely). I had a Silverlight client and a WCF service on a different domain. Both use the Cassini web server with different ports on the localhost. I did not include a ClientAccessPolicy.xml file with the service, yet it ran fine. I checked to make sure it was not a hidden file (you know, show files in Visual Studio). Nope, it was not there.
Next I ran the Web Development Helper tool to check if Silverlight was even looking for the ClientAccessPolicy.xml file. It wasn’t. So then I checked to make sure the domains were indeed different. They were. What the heck was going on!!!!
Every time I ran the application the Silverlight UI loaded itself with data. Where was it coming from? Where was it coming from? Where was it coming from?
Then it hit me … I had put first tested the app with dummy data. Basically commented out the service call with loading hard coded data as a test at one point early on. So everything was working just fine … there was no cross domain call.
I am ashamed to say that this whole process took me about 20-30 minutes to figure out. It was about 2am which explains a lot. Lesson learned … sleep more than 4 hours a night!