Click here to Skip to main content
Click here to Skip to main content
Go to top

Testing Silverlight 2 code with Silverlight 3 and moving to Silverlight 3

, 21 Oct 2009
Rate this:
Please Sign up or sign in to vote.
This article describes my experience with upgrading to Silverlight 3 and the steps taken to ensure our code would work.

So I've seen the release of Silverlight 3 coming for a while now and we've had some discussion about upgrading or not. In the end we concluded that the only reason not to upgrade would be a big impact on our existing application. We decided we would have to wait for the final release before testing it with our current code.

I've heard a lot about backwards compatibility, but I've heard that before with other upgrades and I had a lot of disappointment when actually trying that out. When it comes to backwards compatibility I guess seeing is believing. So last week I took some time to check out the upgrade to Silverlight 3.

To make sure I wouldn't do anything to my own development environment I decided to take a virtual machine and test it on that. Here is what steps I planned to test our application with Silverlight 3:

  1. Install the Silverlight 3 Runtime
  2. Test our application with the Silverlight 3 Runtime
  3. Install a Silverlight 3 development environment
  4. Change the .aspx page to use the object tag instead of the asp:Silverlight control
  5. Get the complete solution to compile
  6. Get the application to run
  7. Test for behavior changes

The first two steps were a breeze and everything worked as expected. This was great, but I had somewhat expected this as the Silverlight 3 Runtime was still handling my application as if it was a Silverlight 2 application. Test passed.

Because all I wanted to do with the development environment was test the Silverlight 3 migration of our client software, I decided to use the new Microsoft Web Platform Installer to setup the tools needed. I haven't tried it before, so I didn't know what to expect. Actually I had only one surprise during setup, which was with the installation of IIS. It requested me to insert the disks for, in this case, Windows XP SP2, so it could copy the files for IIS from that disk.

Other than that, which is still a logical choice as IIS is obviously part of the Windows license you have, everything was downloaded and installed automatically and I was done installing everything in two hours, while reading up on breaking changes between Silverlight 2 and 3 (weird for a backwards compatible release, right :-p). All in all I was pleasently surprised by this great new solution from Microsoft and I hope they soon allow us to install your licensed version of Visual Studio trough the WPI.

Now that I was ready to test the actual upgrading of my application to Silverlight 3, I copied the sources to my virtual machine and opened the solution with Visual Web Developer. Apart from some mistakes where I forgot to copy some linked files, it opened and converted my solution without any hickup. After putting in the missing files, it compiled without problems. I pressed F5 and waited with anticipation ... it worked on the first try! However, I was going a little to fast as I didn't replace the asp:Silverlight tag with the object tag and it was still running with the famous quirks mode enabled (as the minimal version still pointed to Silverlight 2). I replaced the asp:Silverlight tag with the object tag as it looks below:

<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," 
    type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/someapp.xap"/>
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0"
    style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight"
    style="border-style: none"/>
</a>
</object>
<iframe id="_sl_historyFrame" style='visibility:hidden;height:0;width:0;border:0px'>
</iframe>
</div>

I ran the application again ... and it still worked as expected! After some more testing, the only change in behavior that I could find in our application was with the ListBox.ScrollIntoView method. In Silverlight 2, if you would call this with the last item in the listbox, it would scroll it into view, but it would still be at the bottom of the screen. In Silverlight 3, if you call this with the last item, it will actually scroll the item to the top of the listbox, showing empty space below it. As this is the preferred behavior in our case, I haven't done any research to see if I could change it.

All in all, this has been one of the most painless migrations I have experienced ever. Microsoft, my compliments on a job well done.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

mrjvdveen
Software Developer (Senior) CTB Personele Systemen
Netherlands Netherlands
Since early 2001 I've been working full time as a software developer and since 2004 I've been working mostly with Microsoft technology.
I started out as a product developer, but after a few years I switched to a project company where my roles ranged from developer up to consultant and from team lead and coach to manager.
Eventually I switched jobs and focused on the consultant part but now I'm back where I started out and I'm building a product once again.

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 21 Oct 2009
Article Copyright 2009 by mrjvdveen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid