Silverlight reduces xap package size through application cache-dynamic DLL Loading

Source: Internet
Author: User
    • Silverlight cache first registration ation

I. Overview

When you open the same Silverlight site, the Silverlight application must be reloaded every time.ProgramPackage (. xap file), thus greatly reducing the user experience. Therefore, Microsoft provides application library caching in Silverlight 3.0 to solve this defect.

Application Assembly slowdown includes two parts:

1. Assembly caching of Silverlight itself;

2. Custom Assembly cache.

The following describes how to implement the Assembly Cache:

Ii. Assembly Cache of Silverlight

Silverlight provides many assemblies in its SDK. These assemblies can be configured to reload these assemblies only when they need to be used or have a higher version. The configuration steps are as follows:

1. Select the Silverlight project to be configured in application "program resource manager;

2. Right-click and select "properties ";

3. Select the "Silverlight" card on the property configuration page, and select "reduce xap size by using application library cache" on the Silverlight page ".

The above steps complete the relevant configuration, and now re-compile the entire solution, after the compilation is successful, you can go to the clientbin folder of the web project, some projects reference the Silverlight Assembly ZIP file, and the xap file size is reduced.

Iii. Custom Assembly Cache

The Assembly used by the custom Assembly Cache must be a strongly-named assembly (add method: omitted). The configuration steps are as follows:

1. Find the assembly to be cached in the bin/DEBUG directory of the Silverlight project;

2. Add the ing file of the corresponding assembly in the bin/debug of the Silverlight project. The file name is the file name of the corresponding assembly and is extended. extmap. XML (for example, the Assembly name is Microsoft. windows. controls. DLL, corresponding to the Microsoft ing: Microsoft. windows. controls. extmap. XML );

3. Open the ing file in notepad and enter the following content:

<? XML version = "1.0"?>

<Manifest xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: XSD = "http://www.w3.org/2001/XMLSchema">

<Assembly>

<Name> Microsoft. Windows. Controls </Name>

<Version> 2.0.21027.1502 </version>

<Publickeytoken> 31bf3856ad364e35 </publickeytoken>

<Relpath> Microsoft. Windows. Controls. dll </relpath>

<Extension downloaduri = "microsoft.windows.controls.zip"/>

</Assembly>

</Manifest>

Note:

Name: name of the corresponding assembly;

Version: corresponding to the assembly version number. Get the version number: Click the referenced DLL and click Properties.

Publickeytoken: Public Key tag (obtained through Sn-T <assemblyname> In vistual studio command line tool );

Relpath: The full name of the Assembly file;

Downloaduri: To download the compressed package of the Assembly, it must be a zip file. You can specify an absolute path. In this example, it is a relative path;

NOTE: If multiple sets have the same downloaduri, the compilation system will compress these sets into the same zip file.

The above steps complete the relevant configuration, and now recompile the entire solution. After the compilation is successful, you can find the corresponding compressed package in the clientbin folder of the web project (in this example: microsoft.windows.controls.zip ).

In addition, you can open the appmanifest. XAML file in the xap file of Silverlight. The corresponding deployment. externalparts section is added.

<Deployment. externalparts>

<Extensionpart source = "microsoft.windows.controls.zip"/>

</Deployment. externalparts>

Vi. Summary

When using custom Assembly Cache, you must also select "reduce xap size by using application library cache ".

The above content reference: http://msdn.microsoft.com/en-us/library/dd833069%2 8vs. 95% 29. aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.