我在 silverlight 中使用 MEF 从辅助 xap 文件动态加载一些插件。此辅助 XAP 文件是从引用各种插件项目的项目构建的,所有这些项目都是针对主 xap 文件中已有的 dll 构建的。
因此,我想要非常明确地控制哪些 dll 最终出现在这个辅助 xap 中。包含主 xap 文件中的任何 dll 都是多余的(并且还会导致 MEF 重组出现问题)。但 Visual Studio 似乎坚持包含各种依赖的 dll,即使 CopyLocal 属性仅针对插件项目的引用设置为 True。
到目前为止,我发现唯一有效的方法是在构建辅助 xap 的顶级项目中添加对探针始终包含的 dll 的显式引用,并在引用属性中将 CopyLocal 设置为 False。但随着依赖关系的变化,这很脆弱。
我这个想法是不是错了?我是否应该为每个插件 dll 构建一个单独的 xap(在这种情况下,将所有引用的 CopyLocal 设置为 false 似乎可行)?
I'm using MEF in silverlight to dynamically load some plugins from a secondary xap file. This secondary XAP file is built from a project that references various plugin projects, all of which are built against dlls that are already in the primary xap file.
As such, I want pretty explicit control over which dlls end up in this secondary xap. Including any dlls from the main xap file is redundant (and also causes issues with MEF recomposition). But Visual Studio seems to insist on including various dependent dlls even when the CopyLocal property is only set to True for the references to the plugin projects.
So far the only thing I've found that works is to add explicit references to probelmatic always-included dlls in the top-level project that builds the secondary xap, and set CopyLocal to False in the reference properties. But this is brittle as the dependencies change.
Am I thinking about this wrong? Should I just be building a separate xap for each plugin dll (in which case setting CopyLocal to false for all references seems to work)?
发布评论
评论(2)
以及在 Silverlight 项目上设置应用程序库缓存,方法是在项目设置 (source)您需要在同一位置有一个
extmap.xml
文件作为你的共享dll。因此,如果您的 dll 是 Microsoft.Expression.Effects.dll,那么您需要创建(或复制)Microsoft.Expression.Effects.extmap.xml。
它看起来像这样:
版本号应该与 dll 的版本号匹配。
如果您没有公钥令牌,可以将其替换为
null
。这会将 dll 复制到一个单独的 zip 文件中,然后该文件可以由多个 xap 文件共享,或者如果在 xap 文件更改时它不会更改,则仅下载一次。
As well as setting Application Library Caching on your Silverlight project by selecting the "Reduce XAP size by using application library caching" option in your project settings (source) you need to have an
extmap.xml
file in the same location as your shared dll.So if your dll was
Microsoft.Expression.Effects.dll
then you'd need to create (or copy)Microsoft.Expression.Effects.extmap.xml
.It looks like this:
The version number should match the version number of the dll.
If you don't have the public key token you can replace that with
null
.This will copy the dll to a separate zip file which can be then shared by several xap files or only downloaded once if it's not going to change when you xap file changes.
看一下这里:http://msdn.microsoft.com /en-us/library/dd833069(VS.95).aspx
具体来说,请查看标题为“配置程序集以与应用程序库缓存一起使用”的部分。它描述了一种至少非常接近您正在寻找的东西的方法。
Take a look here: http://msdn.microsoft.com/en-us/library/dd833069(VS.95).aspx
Specifically, look at the section entitled "To configure an assembly for use with application library caching". It describes a method for doing something that's at least pretty close to what you're looking for.