xap files getting too big

Topics: Prism v4 - Silverlight 4
Apr 2, 2011 at 10:15 AM



I have no images in my client projects, yet each module is quite big.

I have two modules and a shared infrastructure project and the shell project.


Shell is 642 KB.

NavigationModule 586 KB

ContactModule 835 KB


Thats quite massive.  Is there a way to reduce it? Is it because of Prism?



Apr 4, 2011 at 4:52 PM

A google search revealed that you can try renaming to zip and try unpacking then repacking with higher compression.  

Apr 5, 2011 at 12:49 AM

Hi Houman,

You can check the following links in order to achieve your requirement:


On the other hand, Prism provides the means for achieving background downloading of Xap files, so as to minimize the application start-up time. You might find the Downloading Remote Modules in the Background section in the Modularity Chapter of the Prism MSDN documentation useful to this purpose.


I hope you find this information useful.


Miguel Bronzovic

Apr 13, 2011 at 7:26 AM

Sorry for late response I had forgotten to subscribe to this topic.

Thank you Miguel for the solution.  This looks very promising. :)

Kind Regards,


Aug 4, 2011 at 6:06 PM
Edited Aug 5, 2011 at 12:03 PM

Hi guys,


My project is finally ready to be deployed and since days I am fighting to reduce the XAP size.  It goes quite well the tricks above helped quite a bit.

Now back to PRISM documentation, it suggests to utilize the Application Library Cache.  I have already done an extensive research on how it should work. I have enabled the XAP reduction checkbox and after building I can see how the XAP's have been reduced significantly and all the dependencies now lie as ZIP files next to them.  It all looks great.

But when I start the application over VS 2010, I get a javascript error message:

Microsoft JScript runtime error: Unhandled Error in Silverlight Application An exception occurred while initializing module 'NavigationModule'.     - The exception message was: An exception has occurred while trying to add a view to region 'NavRegion'.     - The most likely causing exception was was: 'System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'SalesContactManagement.Modules.NavigationModule.Views.CoverFlow' that matches the specified binding constraints threw an exception. [Line: 48 Position: 46] ---> System.IO.FileNotFoundException: Could not load file or assembly 'Telerik.Windows.Controls.Navigation, Version=2011.2.712.1040, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The system cannot find the file specified.   at SalesContactManagement.Modules.NavigationModule.Views.CoverFlow.InitializeComponent()   at SalesContactManagement.Modules.NavigationModule.Views.CoverFlow..ctor()   --- End of inner exception stack trace ---   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)   at SalesContactManagement.Modules.NavigationModule.Views.NavigationView.InitializeComponent()   at SalesContactManagement.Modules.NavigationModule.Views.NavigationView..ctor(NavigationViewModel viewModel)   at BuildUp_SalesContactManagement.Modules.NavigationModule.Views.NavigationView(IBuilderContext )   at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)'.    But also check the InnerExceptions for more detail or call .GetRootException().     - The Assembly that the module was trying to be loaded from was:SalesContactManagement.Modules.NavigationModule, Version=, Culture=neutral, PublicKeyToken=null    Check the InnerException property of the exception for more information. If the exception occurred while creating an object in a DI container, you can exception.GetRootException() to help locate the root cause of the problem.      at Microsoft.Practices.Prism.Modularity.ModuleInitializer.HandleModuleInitializationError(ModuleInfo moduleInfo, String assemblyName, Exception exception)   at Microsoft.Practices.Prism.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo)   at Microsoft.Practices.Prism.Modularity.ModuleManager.LoadModulesThatAreReadyForLoad()   at Microsoft.Practices.Prism.Modularity.ModuleManager.IModuleTypeLoader_LoadModuleCompleted(Object sender, LoadModuleCompletedEventArgs e)   at Microsoft.Practices.Prism.Modularity.XapModuleTypeLoader.RaiseLoadModuleCompleted(LoadModuleCompletedEventArgs e)   at Microsoft.Practices.Prism.Modularity.XapModuleTypeLoader.HandleModuleDownloaded(DownloadCompletedEventArgs e)   at Microsoft.Practices.Prism.Modularity.XapModuleTypeLoader.IFileDownloader_DownloadCompleted(Object sender, DownloadCompletedEventArgs e)   at Microsoft.Practices.Prism.Modularity.FileDownloader.WebClient_OpenReadCompleted(Object sender, OpenReadCompletedEventArgs e)   at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)   at System.Net.WebClient.OpenReadOperationCompleted(Object arg)


In the CoverFlow Class ctor I have nothing there but 

public CoverFlow()

I think PRISM doesnt like the XAP reduction feature that much. Any idea this regarding?


Many Thanks,


Aug 6, 2011 at 10:11 AM
Edited Aug 6, 2011 at 12:33 PM

I have found the problem in this case. 

The problem lies in 3rd party Telerik controls.  There you can specify an Application wide theme like this: 

private void Application_Startup(object sender, StartupEventArgs e)
            //StyleManager.ApplicationTheme = new Windows7Theme();
            new Bootstrapper().Run();


Don't do it. Since the App.xaml is defined in Shell, somehow Telerik has problems applying this to the underlying modules. Just apply the theme directly on the module's views rather than central like here.


Then it works. :)