On Silverlight 4 Beta / Silverlight 3 backward compatibility

Edit: Clarified the term quirks mode which Silverlight 4 implements to ensure compatibility with existing Silverlight 3 applications

Silverlight 4 Beta has publicly been among us for over a week now, and the customer I’m currently working for is jumping on the Silverlight 4 bandwagon thanks to its slew of new features. A very legitimate question we had when “porting” his application to Silverlight 4 / Visual Studio 2010 was about the way Silverlight 4 handled backward compatibility for existing Silverlight 3 applications and code. Here is a short brief on the subject :

  • Silverlight 4 is not an incremental update like .NET 3.0 was for .NET 2.0; this means that the runtime has evolved between the two versions
  • Silverlight 4 features a quirks mode to make sure your Silverlight 3 applications run as they always did. Technically, the Silverlight runtime does this based on the XAP’s manifest : if a runtime version prior to 4.0 is specified, Silverlight runs in quirks mode. This mode faithfully reproduces the behavior of previous runtimes (Silverlight 3, but also 1 and 2) by wrapping around changes between versions.
    When upgrading your application to Silverlight 4 check for binary assemblies (DLL) compiled with Silverlight 3 included in your new XAP file, as they will run outside of quirks mode. As it is very often the case, mixing binary versions should be avoided.
    • MyApp.xap (targeting SL4)
    • Main.dll
      • SL4Assembly.dll
      • SL3Assembly.dll <- this will not run in quirks mode!
  • When using Prism, since all assemblies load in the same AppDomain, they will all run in the mode defined by the main XAP’s manifest

In order to read AppManifest.xml, just explore the XAP file as if it were a ZIP file.

Note: Neat! My previous post was featured on This Week On Channel 9 !

Skip to main content