Silverlight:如何处理标准程序集(第 2 部分)

发布于 2024-09-12 23:14:14 字数 1224 浏览 3 评论 0原文

有必要将“标准”程序集移出 xap 文件(Silverlight 4 应用程序)。我遇到了类似的问题(Silverlight:如何处理标准程序集)并得到具有深入解释的良好链接。但并非一切都清楚。

在我打开“使用应用程序库缓存减少 XAP 大小”后,我的 xap 文件的大小减少了两倍,以下程序集被移出到单独的 zip 文件中:

  • System.ComponentModel.DataAnnotations;
  • System.Windows .Controls、
  • System.Windows.Controls.Data、
  • System.Windows.Controls.Data.Input、
  • System.Windows.Controls.Input、
  • System.Windows.Controls.Navigation、
  • System.Windows.Controls.Toolkit 但

仍然有一些其他看起来像是移入单独文件的好候选者:

  • GalaSoft.MvvmLight.SL4、
  • Microsoft.Practices.ServiceLocation、
  • Microsoft.Practices.Unity.Silverlight、
  • System.Windows.Controls.Toolkit.Internals。

所有这些程序集都是从 Silverlight 应用程序(以及使用这些程序集的 Silverlight 项目)引用的

  • Q1. 如何将这 4 个程序集移动到单独的 zip 文件中 也

非常感谢!

PS 也许我的问题的答案在正文中:

添加对 Silverlight SDK 中的库程序集或任何库程序集的引用 程序集附带有效的 assemblyShortName.extmap.xml 映射 文件。

但我不明白这是什么意思。如果我理解正确,我需要将这些程序集(我想要移出)的引用添加到 Silverlight SDK 中。但如何做到这一点呢?谢谢。

It is necessary to move 'standard' assemblies out of the xap-file (Silverlight 4 application). I had a similar problem (Silverlight: how to handle standard assemblies) and got a good link with deep explanations. But not all is clear there.

After I've switched on the 'Reduce XAP size by using application library caching" the size of my xap-file was decreased in twice, the following assemblies were moved out into separate zip-files:

  • System.ComponentModel.DataAnnotations;
  • System.Windows.Controls,
  • System.Windows.Controls.Data,
  • System.Windows.Controls.Data.Input,
  • System.Windows.Controls.Input,
  • System.Windows.Controls.Navigation,
  • System.Windows.Controls.Toolkit;
  • System.Windows.Data.

But still there are few others that seems like good candidates to be moved out into separate files:

  • GalaSoft.MvvmLight.SL4,
  • Microsoft.Practices.ServiceLocation,
  • Microsoft.Practices.Unity.Silverlight,
  • System.Windows.Controls.Toolkit.Internals.

All these assemblies are referenced from the Silverlight application (and also from Silverlight Projects that use these assemblies).

Could you please explain:

  • Q1. What is a difference between these mentioned assemblies?
  • Q2. How to move these 4 assemblies into a separate zip files too?

Thank you very much!

P.S. Probably, the answer on my question is in the text:

Add a reference to a library assembly in the Silverlight SDK, or to any
assembly accompanied by a valid assemblyShortName.extmap.xml mapping
file.

But I don't understand what does that mean. If I correctly understand, I need to add a reference on those assemblies (that I want to move out) into a Silverlight SDK. But how to do that? Thanks.

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

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

发布评论

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

评论(1

一指流沙 2024-09-19 23:14:14

A1) 两个列表之间的区别在于,第一组程序集已经定义了必要的 *.extmap.xml 文件,Visual Studio 使用这些文件自动将每个程序集打包在 zip 文件中,然后将其独立缓存在客户端(通过网络浏览器)。

如果您查看此文件夹(根据需要调整安装驱动器位置):

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client

您将看到有 *.extmap.dll 文件对于几乎所有常见的 Silverlight 程序集(如果不是全部)。例如,以下是 System.Windows.Data.extmap.dll 的内容:

<?xml version="1.0"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <assembly>
    <name>System.Windows.Data</name>
    <version>2.0.5.0</version>
    <publickeytoken>31bf3856ad364e35</publickeytoken>
    <relpath>System.Windows.Data.dll</relpath>
    <extension downloadUri="System.Windows.Data.zip" />
  </assembly>

</manifest>

如果您按照位于 此处,您将看到它是如何构建的。大多数部分应该是显而易见的,唯一不寻常的方面是可能的扩展元素。通过将文件名放入 downloadUri 属性中,程序集会自动打包到该文件中(它是一个 zip 文件,但扩展名可以是您想要的任何内容)。

当您引用诸如 System.Windows.Data 之类的程序集时,它会发现此文件并在生成期间使用它来创建 zip 文件 System.Windows.Data.zip。如果两个或多个引用的程序集共享相同的 downloadUri 目标文件名,则它们将在构建时自动合并为单个文件。

A2)
您可以遵循该模式并为第二个列表中的每个程序集创建 *.extmap.dll 文件。

该 xml 文件应位于与您要创建的程序集相同的文件夹中。

对于 GalaSoft.MvvmLight.SL4,(作为示例,我没有安装此组件,也不知道它是否已签名)。该文件将被命名为:

GalaSoft.MvvmLight.SL4.extmap.xml

它的内容将如下所示:

<?xml version="1.0"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <assembly>
    <name>GalaSoft.MvvmLight.SL4</name>
    <version>#.#.#.#</version> <!-- needs the version number -->
    <!-- if there's a public key token, put it in this element, and
        uncomment it -->
    <!-- <publickeytoken></publickeytoken> -->
    <relpath>GalaSoft.MvvmLight.SL4.dll</relpath>
    <extension downloadUri="GalaSoft.MvvmLight.SL4.zip" />
  </assembly>
</manifest>

一旦该文件存在,Visual Studio 将使用它来构建名为 GalaSoft 的 zip 文件.MvvmLight.SL4.zip。一旦您引用 dll,这一切就会自动发生(只要 extmap.xll 文件与原始程序集并排)。

A1) The difference between the two lists is that the first set of assemblies has already defined the necessary *.extmap.xml files, which are used by Visual Studio to automatically package each assembly in a zip file, which is then cached independently on the client (via the web browser).

If you look in this folder (adjust the installation drive location as needed):

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client

You'll see that there are *.extmap.dll files for nearly every common Silverlight assembly (if not all). For example, here's the content of System.Windows.Data.extmap.dll:

<?xml version="1.0"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <assembly>
    <name>System.Windows.Data</name>
    <version>2.0.5.0</version>
    <publickeytoken>31bf3856ad364e35</publickeytoken>
    <relpath>System.Windows.Data.dll</relpath>
    <extension downloadUri="System.Windows.Data.zip" />
  </assembly>

</manifest>

If you follow the documentation located here, you'll see how this is built. Most parts should be obvious, with the only unusual aspect being the extension element potentially. By putting a file name in the downloadUri attribute, the assembly is automatically packed into that file (it's a zip file, but the extension can be anything you'd like).

When you reference the assembly such as System.Windows.Data, it discovers this file and uses it during the build to create the zip file, System.Windows.Data.zip. If two or more referenced assemblies both share the same downloadUri destination file name, they will be automatically combined into a single file at build time.

A2)
You can follow that pattern and create *.extmap.dll files for each of the assemblies you have in the second list.

The xml file should be located in the same folder as the assembly that you'd create.

For the GalaSoft.MvvmLight.SL4, (as an example, I don't have this component installed, and don't know if it's signed). The file would be named:

GalaSoft.MvvmLight.SL4.extmap.xml

It's contents would look something like this:

<?xml version="1.0"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <assembly>
    <name>GalaSoft.MvvmLight.SL4</name>
    <version>#.#.#.#</version> <!-- needs the version number -->
    <!-- if there's a public key token, put it in this element, and
        uncomment it -->
    <!-- <publickeytoken></publickeytoken> -->
    <relpath>GalaSoft.MvvmLight.SL4.dll</relpath>
    <extension downloadUri="GalaSoft.MvvmLight.SL4.zip" />
  </assembly>
</manifest>

Once that file exists, Visual Studio will use it to build a zip file named GalaSoft.MvvmLight.SL4.zip. This all happens automatically once you reference the dll (as long as the extmap.xll file is side-by-side with the original assembly).

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