问题
I'm currently doing some work on a silverlight LOB application i wrote for a customer..
When i deploy i can't help noticing how big the xap file is (4mb) and considering it's not a massive app it seems a little unusual.
I am using the telerik silverlight toolkit (but only including the required themes - 2 I think)..
There's about 1mb of images (which is maybe a bit too much for a LOB app)..
Is this average for a silverlight application?
Whats the average size of your xap files?
How would I go about "minifying" or compressing my xap file?
回答1:
If you open the .xap file with an archive reader like 7-Zip, or rename it to .zip and open it, you can get an idea of where the size is coming from.
You can cut down on the size of the file by removing any References that aren't used. If you're not sure if something is used or not, remove it and see if the app still builds. If not, put it back in.
In your Silverlight project's Properties, in the Silverlight section, you can check the "Reduce XAP size by using application library caching" checkbox to have it move some of the DLLs out to separate .zip files instead of being included in the XAP. That way, if your app changes, your users don't have to download all of the included DLLs again.
If it's still too large for your tastes, you might want to look at moving the images out of the .xap file.
回答2:
You can minimize the xap file by:
Reduce image sizes
Implement styles using xaml instead of using static images
Remove images - I never did it in my applications, but you can specify an image url instead of embedding it inside your xap file, this would make your xap file smaller, but will have a minor ui-effect as the images will take some time (depending on the client's network) to download the images.
Split your application into multiple xap files and dynamically load the required xap modules (frameworks such as MEF and PRISM will make it very easy)
回答3:
A quick way to make your xap file size smaller is to check the 'Reduce XAP size by using application library caching' checkbox in the Silverlight tab of you project. For more info on what it does : How to: Use Application Library Caching
来源:https://stackoverflow.com/questions/6790377/is-my-xap-file-too-big-and-if-so-how-do-i-make-it-smaller