2
votes

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

2 Answers

1
votes

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:

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

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.

0
votes

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.