Silverlight 3 Reduce XAP size by using application library caching application, package download

Source: Internet
Author: User

The IsolatedStorageFile class was first used to cache the Silverlight program. The program can be opened more quickly next time. This option is available in the SL Project Properties of VS occasionally found one day.

So I tried to search for information on the Internet. The result is obvious. xap files with more than 400 k are separated into multiple files. The last xap file is only 14 k in size.

 

The production process of this demo is recorded for reference.

 

1. The project structure is as follows:

2. Compile and view the size of the generated Xap file. 452KB.

3. Open the properties page of the PEMS. Sl. ui sl project.

4. Compile the solution and view the new results.

After being generated, the Three dynamic link libraries of. Navigation. Controls. Linq are separately packaged as zip files. They are stored in the ClientBin directory. In this way, when the client is in use,. SL will be automatically downloaded for you.

Because of my PEMS. sl. the UI project uses PEMS. sl. controls and PEMS. common. model Project. I also need to make these two projects work with Navigation. controls. they are the same. the following is a detailed description.

Transformation of PEMS. Sl. Controls and PEMS. Common. Model projects.

1. Generate PEMS. Sl. Controls and PEMS. Common. Model as strongly typed dynamic link libraries.

1. Use the VS tool sn to generate a key.

Sn-k key. snk

Sn-p key. snk key. public. snk

Note down the public token viewed by sn-t key. public. snk. It will be important later

2. Generate a key in the PEMS. Sl. Controls project attribute.

3. Add [assembly: AssemblyKeyFile ("key. public. snl")] To the AssemblyInfo. cs file.

 

4. Create an AssemblyName. extmap. xml file in the project. My name is PEMS. Sl. Controls. extmap. xml.

The content of this file is:

 

1 <? Xml version = "1.0"?>
2 <manifest xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
3 xmlns: xsd = "http://www.w3.org/2001/XMLSchema">
4 <assembly>
5 <name> PEMS. Sl. Controls </name>
6 <version> 1.0.0.0 </version>
7 <publickeytoken> 55a4a48c2765ae41 </publickeytoken>
8 <relpath> PEMS. Sl. Controls. dll </relpath>
9 <extension downloadUri = "PEMS.Sl.Controls.zip"/>
10 </assembly>
11
12 </manifest>

Replace the relevant values in your project. Change the attributes of this XML file. Change to always copy to the output directory.

PEMS. Common. Model has the same settings as PEMS. Sl. Controls.

Try again now.

PMES. Common. Model and PEMS. Sl. Controls are all compressed into a zip package.

Now let's see how big PEMS. Sl. UI. xap is.

Changed from 452KB. to 210 KB. All others are dynamic downloads.

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.