
Most people who know me, also know that I like to fiddle with technology in my own free time. It's one of those things that I simply can't let go, maybe later but certainly not at the moment.
One of the things I'm currently quite enthuisastic about is the new version of Silverlight. Microsoft has finally come up with a technology that combines web, wpf and the flexibility offered by .NET. Since I got so much to do with CompositeWPF and WPF in general I thought I'd give PrismAg a try and build my self a photoviewer silverlight app, combining a lot of stuff that is bound to give me a puzzle 😉
Let's get to the point here. I created a silverlight application and a ADO.NET data service and connected the two so that I could display album and photo information from a database I already got running for another sample. Thinking this would work right away I fired up the debugger and got a nice error served up telling me that a javascript call failed.
This got me wondering quite a bit, because I only wrote C# and a bit of XAML. So where does the javascript come from? As it turns out, Silverlight generates javascript to work with ADO.NET data services and the error I got was because I violated the cross domain policy.
The moral of the story? Always check documentation and always services that are on the same host as the silverlight application. You can use external services, but only if you created your own proxy. It isn't pretty, but it will save you two hours of puzzeling ;P
— UPDATE: I thought silverlight was generating javascript for the call to the service, but it turns out that it generates javascript to report the error to the client browser. They have hard coded limitations in the mechanics to do webservice calls and http calls, so you can't do anything that would cause a security problem.