In this post , I talk about how to improve the performance of your Silverlight app using the Assembly Caching feature.
Performance is key to any application and Silverlight application is no different. In this post I will show you how you can increase the performance of your app by using assembly caching feature in Silverlight.
What is Assembly Caching
You can gain the substantial performance in your application if your download time of the xap file can be reduced. Assembly caching feature allow to reduce this size of xap file by partitioning your external assemblies in separate zip files.If you view the properties of your Silverlight project. You would find a checkbox with the text “ Reduce XAP size by using application library caching
”. See the screen shot below.
Once this checkbox is checked then instead of creating a single large xap file it will create separate zip (see the diagram below) files of all the external assemblies and the xap file will only contain Silverlight core assemblies.
Importance of Assembly Caching
This feature does not reduce the initial download time of your application, but it really helps when it comes to deploying the updates for your app. If this feature is off then the user has to download the entire application including the external assemblies with every update. But when this feature is on the user will only download the xap file without the external assemblies getting downloaded because these assemblies are cached in the user’s browser cache. These files only get downloaded when these files are changed on the server.
How it works
Every assembly which is getting cached corresponds to the external part manifest file on the same path from where it is being referenced. This file can be identified by the following name [AssemblyName].extmap.xml. So for example if we talk about System.ServiceModel.Web.Extensions assembly, its corresponding manifest file name will be in the same location with the filename as System.ServiceModel.Web.Extensions.extmap.xml. The AppManifest.xaml file , located in xap file references these external assemblies. The content of this file is listed below.
<AssemblyPart x:Name="TestBizApp" Source="TestBizApp.dll" />
<ExtensionPart Source="System.ComponentModel.DataAnnotations.zip" />
<ExtensionPart Source="System.ServiceModel.DomainServices.Client.zip" />
<ExtensionPart Source="System.ServiceModel.DomainServices.Client.Web.zip" />
<ExtensionPart Source="System.ServiceModel.Web.Extensions.zip" />
<ExtensionPart Source="System.Windows.Controls.Data.Input.zip" />
<ExtensionPart Source="System.Windows.Controls.zip" />
<ExtensionPart Source="System.Windows.Controls.Navigation.zip" />
<ExtensionPart Source="System.Windows.Data.zip" />
Every developer must think upfront for gaining performance improvements. He or she must leave no stone unturned to gain any performance improvements. If your project is referenced to your own external assembly you must try to cached it that also. For this the assembly should be signed. Alex Golesh
has utility to generate the extmap files of your custom assemblies.
PS : Assembly Caching feature is not available for Out of Browser Silverlight Apps.