rem
rem

Reputation: 17085

Do long class names affect the size of a XAP file?

There is a custom control in my Silverlight application, which is put on the canvas about one thousand times. I'm concerned about the size of a XAP file of this app.

Will XAP file contain explicitely the names of this control in the same quantity? Will I reduce the size of the XAP file by changing the name of the custom control from, say, 10 letters to only 2 letters. How I can calculate the impact of the length of the class names on the final size of the XAP file?

Upvotes: 2

Views: 229

Answers (3)

iCollect.it Ltd
iCollect.it Ltd

Reputation: 93601

If size is important to you I think you are worrying about the wrong thing. You are more likely to include unused code, or DLLs, or large resources, than have names that are too long. Remember the file is zipped and text compression is very good so the effect of repeating the same long control name 1000s of times is minimal.

Also don't forget to re-zip your XAP files with better zip software (as the zip compression you get in XAP files built by Visual Studio is not optimal!)

You are much better off worrying about progressive loading as most Silverlight apps out there are way too bulky (and take way more than the expected/recommended 8 second attention span of most web-users).

Upvotes: 2

samjudson
samjudson

Reputation: 56893

A XAP file is just a ZIP file containing your compiled binaries. Your XAML files are embedded as resources in those compiled binaries.

So yes - the length of the name of your control will affect the file size of your XAP file.

How much is a different question. The XAP file is a compressed ZIP file. As an example I have a XAP file with 2 DLLs in. One compressed down from 282k to 94k, the other from 46k to 16k.

I would worry more about why your control appears 1000 times in a single page however. Surely there must be a better way of doing this. Perhaps even doing it in code would be easier/better?

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1502835

How I can calculate the impact of the length of the class names on the final size of the XAP file?

Simple answer: you could test it. Build your XAP file, rename the class, rebuild the XAP file, and see what the size difference is, if any.

I'd expect the name of the class to only occur once in the metadata, but if you're giving long names to the instances in the XAML, that may make a difference.

Upvotes: 2

Related Questions