Share on Facebook
This blog post is part of my series of posts taken from a presentation I gave in September on SEO for Silverlight Applications.
The other posts in this series can be found here: Part I, Menu in Html and Silverlight, this is the Sitemap demo
Part II, Show Multiple Silverlight Controls in the Same Page with jQuery
Part III, service layer communicatioons - the Glue between the Silverlight and the WebApp
Part IV, Maintaining Browser History in a Silverlight Application
Now the adventures in Silverlight Begin.
SO – commonly encountered problems. Uh, I'm still really nuts about Silverlight and I get so excited to be able to work in it. So please take that statement and keep it in mind while I rant.
I was recently able to participate in the development of a rather ambitious Silverlight application. One which taught me a lot about how to optimize my time, how to find what's really broken, and how to keep the dang debugger attached.
It seems that the .xap file is cached by the browser. It doesn’t seem like it – it is. The Xap file is Cached by the browser.
So this is Good if you’re a web client and you want good response time. This is REALLY HARD if you’re a Silverlight developer trying to make and test a series of incrementally small changes to your Silverlight application. This is doubly complicated if you've got a Silverlight application that uses a separate .dll for business logic. Changing the Business Logic .dll will not "register" with the environment to send a new xap. Either that, or Internet Explorer doesn't think it should have to download a new .xap file to the client for whatever reason.
You know you've got an old copy of the .xap in your cache if your debugging breakpoints are disabled when the control is loaded in the browser. So although this is easily identified and it is easily fixed by clearing your temporary files, It took me literally DAYS to figure it out. Heck, I tried everything. Close Visual Studio, ReBoot My Computer, Search the Internet for answers. That’s Heartbreaking when you're on a fixed timeline.
So, anyway, here’s the magic combination: Tools/Internet Options/Delete/Delete Files/YES/Close/OK
Remember that, Tools/Internet Options/Delete/Delete Files/YES/Close/OK
That's my new routine, I think I should actually add it as a post build action for my silverlight project. Whenever it gets compiled, it will clear the temporary files before launching the debugger when I F5.
Xaml binding to a non-existant object is another problem you may encounter as I did while working in Silverlight.
Two different bindings that have caused me trouble here. One binding is when you add code to your XAML element to bind it’s data to an object that lives in the code behind. The opening edit screen wil be displayed and you’ll be able to enter text in an input area. But as soon as your focus moves from the first , the screen will go white. If that happens, the object in the code behind is null. Just make sure you always have an object created and that you haven't bound to a null object. (makes sense. :-) )
A second white screen situation results when using these techniques I’ve shown you today, for example where the button.xaml template is inserted into the xaml. If those binding styles aren’t present in your resources somewhere you won’t be able to see what happened and the app won’t work.
Normally when I run into this, I like to solve this problem by loading my control up in BLEND, as Blend provides better feedback in some error conditions. But when the xaml has been added dynamically you need to build a throwaway version of your control to get it into blend – or just be very meticulous in comparing your application resources to the resources your code is inserting.
myRand=parseInt(Math.random()*99999999); // cache buster
As Always, I thank all the generous programmers and contributors who have put these answers up to their Internet sites - you people save my job every day and I would be working in a different line of business if you didn't make your contributions. thanks!