Question

In the past I've used the solution outlined in the following URL to avoid multiple downloads of 3rd party dlls in modular Silverlight applications:

How to optimize the size of silverlight XAP file by removing common files?

However I am working on a Visual Studio 2010/Silverlight 5 solution application where this is not working.

I have a PRISM module let's call it Parent1.csproj that has no references to my 3rdParty dlls but it does have a reference to two other project files which reference the 3rdParty dlls child1.csproj and child2.csproj

child1.csproj and child2.csproj both have "Copy Local" set to false for 3rdParty.dlls but in spite of this the .xap file for Parent1.csproj contains the 3rd party dlls.

If I set child1.csproj and child2.csproj references in the Parent1.csproj file with "Copy Local" set to false then I get a dramatically reduced xap file with no 3rd party dlls but also none of the other code in the child projects that I actually need to be able to run.

It seems as if included project files get their "Copy Local" setting ignored and use the parent "Copy Local" setting instead, and there's no way for me to exclude those 3rdParty.dlls

Have I missed something subtle here? Is there some other way I can avoid downloading those 3rdParty.dlls in multiple modules when the shell application has already downloaded them?

Was it helpful?

Solution

I'm not 100% sure why this problem occurs, but it is related to Prism. The way we've solved it is add references to all the startup project and each of the sub projects even though they're not directly referenced but that project.

  1. Make sure that the "Reduce XAP size by using application library caching" is enabled for all your projects.

  2. Make sure that Parent1.csproj has references to all your 3rd party dlls.

  3. Add these same references to child1.csproj and child2.csproj.

  4. Double check you have extmap files for all your 3rd party dlls. If these are missing the dlls will be loaded into the XAP files.

OTHER TIPS

Adding the references to the module projects and setting Copy Local to false on them will work, which is more or less what the accepted answer describes. However, Application Library Caching is not supported in Prism modules, so that may not work as expected.

If you have a lot of assembly references, adding them in this fashion is not very maintainable. You could also use a post-build step that removes unneeded assemblies from the XAP. Here's a short article that I wrote about how.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top