开发者

Silverlight: how to handle standard assemblies

开发者 https://www.devze.com 2023-01-08 14:24 出处:网络
A usual Silverlight task: to make the size of xap-file smaller. There are a lot of hot-to-do manuals that explain how to make your application modular. But I didn\'t find anyone that explains how to m

A usual Silverlight task: to make the size of xap-file smaller. There are a lot of hot-to-do manuals that explain how to make your application modular. But I didn't find anyone that explains how to make "modular" standard libraries.

The biggest part of my xap-file (1.7Mb, when overall size is 1.8Mb) is occupied by standard assemblies: among them System.Windows.Controls.dll - 370Kb, System.Windows.Controls.Data.dll - 464Kb, etc...

Could you please tell (or give a reference to manual) how开发者_如何转开发 to move these assemblies out of xap file? I could use prism/unity and load them dynamically, but in this case I need to remove references to these assemblies from my Silverlight libraries... and they become uncompilable...

Details: lets imagine, I have "ModuleAView" project, that contains pages for my application. This module is in the separate assembly... but it is still pretty big (it contains all mentioned libraries). If I will move out libraries from the project, my XAML-files became uncompilable.

Please advise. Thanks.


One suggestion is to use Silverlight's assembly file caching option. Documentation and an walkthru may be found here. The overall size of your application won't change, but it's likely that the end user experience, for returning users, will improve as the browser caches the individual assemblies.


Typically, for larger, composite applications, you'd download a host application that takes the "hit" of the DLLs (i.e. if you are using x, y, and z, they will be included in the host). Another option is a lightweight introductory XAP, then download the additional ones in the background.

Either way, the key is to strategize how your projects are related so that you only include the DLLs once. Once you have a XAP file that contains the necessary DLL, any other XAP loaded into the same application can set the reference to "copy-local=false". This means it will still reference System.Windows.Controls.Data.dll, for example, but won't actually keep a copy in the generate XAP.

So again, if your desire is to reduce the footprint and load time of the initial, you might have: Application.xap that fires up and provides the user with navigation, splash screen, etc. It would instantally dynamically load "Libraries.xap" that contains the dependent DLLs (controls, etc) in the background, and finally any other "Module1.xap" and "Module2.xap" would simply reference the DLLs but have copy local set to false.

I have an in-depth example with source code here: http://csharperimage.jeremylikness.com/2010/06/advanced-silverlight-applications-using.html

0

精彩评论

暂无评论...
验证码 换一张
取 消