Silverlight 3 Quick Tip #5: Assembly Caching - DevCorner

Silverlight 3 Quick Tip #5: Assembly Caching

Always wanted to have smaller XAP files and take control of external assemblies, that are not part of core runtime? Using Silverlight toolkit and want to cache this assemblies on client machines to keep the resulting XAP smaller? Well, if so new feature in Silverlight 3 Beta will help you.

To enable assembly caching, in Silverlight project properties check “Reduce XAP size” checkbox:

image

The effect are following: In standard non-checked compilation the XAP file has all the external assemblies being referenced from the application:

The AppManifest.xaml looks like follows:

<Deployment xmlns=http://schemas.microsoft.com/client/2007/deployment 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            entrypointassembly="GpuAccelerationDemo" 
            entrypointtype="GpuAccelerationDemo.App" 
            runtimeversion="3.0.40307.0"> 
    <Deployment.Parts> 
        <AssemblyPart x:Name="GpuAccelerationDemo" 
            Source="GpuAccelerationDemo.dll" /> 
        <AssemblyPart x:Name="System.ComponentModel.DataAnnotations"
            Source="System.ComponentModel.DataAnnotations.dll" /> 
        <AssemblyPart x:Name="System.ComponentModel"
            Source="System.ComponentModel.dll" /> 
        <AssemblyPart x:Name="System.Windows.Ria"
            Source="System.Windows.Ria.dll" /> 
    </Deployment.Parts> 
</Deployment>

The XAP contents is like follows:

image

And the file size is like follows:

image 

To compare, when this option is selected, the AppManifest.xaml will have external references to assemblies, which will be downloaded for the the first time and cached:

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
            EntryPointAssembly="GpuAccelerationDemo" 
            EntryPointType="GpuAccelerationDemo.App" 
            RuntimeVersion="3.0.40307.0">
  <Deployment.Parts>
    <AssemblyPart x:Name="GpuAccelerationDemo" Source="GpuAccelerationDemo.dll" />
    <AssemblyPart x:Name="System.Windows.Ria" Source="System.Windows.Ria.dll" />
  </Deployment.Parts>
  <Deployment.ExternalParts>
    <ExtensionPart Source="http://go.microsoft.com/fwlink/?LinkID=142565" />
    <ExtensionPart Source="http://go.microsoft.com/fwlink/?LinkID=141727" />
  </Deployment.ExternalParts>
</Deployment>

The XAP contents will have less included assemblies:

image

And as a result, the XAP size will be smaller:

image

 

Enjoy,

Alex

Published Sunday, March 29, 2009 11:31 AM by Alex Golesh

Comments

# links for 2009-03-30

links for 2009-03-30

Tuesday, March 31, 2009 12:02 AM by SKOROZSI.NET

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: