Silverlight:如何处理标准程序集

发布于 2024-09-11 07:24:35 字数 481 浏览 0 评论 0原文

一个常见的 Silverlight 任务:减小 xap 文件的大小。有很多热门手册解释了如何使应用程序模块化。但我没有找到任何人解释如何制作“模块化”标准库。

我的 xap 文件的最大部分(1.7Mb,当整体大小为 1.8Mb 时)被标准程序集占用:其中 System.Windows.Controls.dll - 370Kb、System.Windows.Controls.Data.dll - 464Kb 等...

您能否告诉(或提供手册参考)如何将这些程序集移出 xap 文件?我可以使用 prism/unity 并动态加载它们,但在这种情况下,我需要从我的 Silverlight 库中删除对这些程序集的引用...并且它们变得无法编译...

详细信息: 让我们想象一下,我有“ModuleAView”项目,其中包含我的应用程序的页面。该模块位于单独的程序集中...但它仍然很大(它包含所有提到的库)。如果我从项目中移出库,我的 XAML 文件将变得无法编译。

请指教。 谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

赴月观长安 2024-09-18 07:24:35

一项建议是使用 Silverlight 的程序集文件缓存选项。可以在此处找到文档和演练。应用程序的整体大小不会改变,但对于回访用户来说,最终用户体验可能会随着浏览器缓存各个程序集而得到改善。

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.

水波映月 2024-09-18 07:24:35

通常,对于较大的复合应用程序,您需要下载一个接受 DLL“命中”的主机应用程序(即,如果您使用 x、y 和 z,它们将包含在主机中)。另一种选择是轻量级介绍性 XAP,然后在后台下载其他 XAP。

无论哪种方式,关键是制定项目关联方式的策略,以便仅包含 DLL 一次。一旦您拥有包含必要 DLL 的 XAP 文件,加载到同一应用程序中的任何其他 XAP 都可以将引用设置为“copy-local=false”。例如,这意味着它仍然会引用 System.Windows.Controls.Data.dll,但实际上不会在生成的 XAP 中保留副本。

再说一次,如果您希望减少初始的占用空间和加载时间,您可能拥有: Application.xap 启动并为用户提供导航、启动屏幕等。它将立即动态加载“Libraries.xap”在后台包含依赖的 DLL(控件等),最后任何其他“Module1.xap”和“Module2.xap”将简单地引用 DLL,但将复制本地设置为 false。

我在这里有一个带有源代码的深入示例:
http://csharperimage.jeremylikness.com/2010/06/高级-silverlight-applications-using.html

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文