本文介绍了Silverlight的:如何处理的标准组件(部分2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是必要之举标准组件出XAP文件中(Silverlight 4的应用程序)。我有一个类似的问题(http://stackoverflow.com/questions/3329731/silverlight-how-to-handle-standard-assemblies),并得到了深解释一个很好的链接。但并不是所有的至清。

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

在我使用的应用程序库缓存我的XAP文件的大小打开了减少XAP大小减少两次,下面的组件被移出到单独的zip-文件:

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.P​​ractices.ServiceLocation,
  • Microsoft.P​​ractices.Unity.Silverlight,
  • System.Windows.Controls.Toolkit.Internals。

所有这些组件都是从Silverlight应用程序引用(也Silverlight的项目使用这些组件)。

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

能否请您解释一下:

  • Q1。是什么,这些提到的组件之间有区别吗?
  • Q2。如何将这些4集会到一个单独的zip文件呢?

非常感谢你!

P.S。也许,我的问题的答案是于文:

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

添加一个参考Silverlight的SDK库程序集,或任何  装配附有有效assemblyShortName.extmap.xml映射  文件。

不过,我不明白是什么意思。如果我理解正确的,我需要添加这些组件的参考(我想搬出去)到一个Silverlight SDK。但如何做到这一点?谢谢你。

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.

推荐答案

A1)的两个列表之间的区别在于,第一组组件已经定义的必要* .extmap.xml的文件,这是用来由Visual Studio以自动在一个压缩文件,然后将其独立地缓存在客户端上(通过网络浏览器)的每个组件打包。

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)的\微软的SDK \ Silverlight的\ V4.0 \图书馆\客户端

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

您会看到,有几乎每一个普通的Silverlight总成* .extmap.dll文件(如果不是全部)。例如,这里的System.Windows.Data.extmap.dll的内容:

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>

如果你这里遵循位于文档,你会看到这是如何构建的。大部分地区应该是显而易见的,唯一的不同寻常的方面是所述延伸元件可能。通过将文件名中的downloadUri属性,该组件会自动打包成文件(它是一个压缩文件,但扩展名可以是任何你喜欢)。

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).

当你引用的程序集,如System.Windows.Data,它发现此文件,并使用它的构建过程中创建的zip文件,System.Windows.Data.zip。如果两个或多个引用的程序共享同一个downloadUri目标文件名,它们将自动组合成在构建时单个文件。

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)您可以按照这种模式,并为每个你在第二个列表中的组件创建* .extmap.dll文件。

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

XML文件应位于同一文件夹中,你会创建装配。

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

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

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>

在该文件存在,Visual Studio将使用它来构建一个名为zip文件的 GalaSoft.MvvmLight.SL4.zip 。这一切都自动发生的,一旦你引用的DLL(只要extmap.xll文件并排侧与原组件)。

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).

这篇关于Silverlight的:如何处理的标准组件(部分2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!