Module with style throw exception

Topics: Prism v4 - Silverlight 4
Feb 20, 2013 at 7:41 AM
Major -> has a defined style in bootstrapper solution.
ModuleA-> use major solution style
ModuleB-> use major solution style

after all ,we change this to use mef.

Major -> has a defined style in bootstrapper solution.
ModuleA-> demond load
ModuleB-> demond load

but raise an exception when page load. from it, it says could find the resouce, but I have moved all style into the module.
here is the question:
How about the module use the style from other solution. Thank you in advance.


Microsoft.Practices.Prism.Modularity.ModuleInitializeException: An exception occurred while initializing module 'AdministrationModule'.
- The exception message was: An exception has occurred while trying to add a view to region 'MainRegion'. 
- The most likely causing exception was was: 'System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) Cannot find a Resource with the Name/Key DashBoardTitleTextBoxtStyle [Line: 26 Position: 11]

Resulting in: An exception occurred while trying to create an instance of type 'Administration.Controls.DataManagement'.
  protected override void ConfigureAggregateCatalog()
        {
            base.ConfigureAggregateCatalog();
            AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(EstimatorBootstrapper).Assembly));
            AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ShellViewModel).Assembly));
            AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(EstimateModule).Assembly));
            //AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(AdministrationModule).Assembly));
            AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(UploadTemplateViewModel).Assembly));
            AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ActivationManager).Assembly));
             //AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ReportsModule).Assembly));
            AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ReportsViewModel).Assembly));
        }
inishell

IRegionManager _regionManager = ServiceLocator.Current.TryResolve<IRegionManager>();
        IAuthenticationService _service = ServiceLocator.Current.TryResolve<IAuthenticationService>();
        IModuleManager _moduleManager = ServiceLocator.Current.TryResolve<IModuleManager>();
        if (_service != null && _moduleManager != null)
        {

            _moduleManager.LoadModule("EstimateModule");



            if (_service.CurrentUser.UserInformation.IsLeader())
            {
                _moduleManager.LoadModule("ReportsModule");

            }
            else if (_service.CurrentUser.UserInformation.IsDataAdminUser() || _service.CurrentUser.UserInformation.IsTemplateAdminUser())
            {
                _moduleManager.LoadModule("AdministrationModule");
            }

        }
inmodule
 [ModuleExport(typeof(EstimateModule))]
    public class EstimateModule : IModule
    {
        public void Initialize()
        {
            IRegionManager _regionManager = ServiceLocator.Current.TryResolve<IRegionManager>();
            if (_regionManager != null)
            {
         
                _regionManager.RegisterViewWithRegion("MainRegion", typeof(IDashboard));
                _regionManager.RegisterViewWithRegion("MainRegion", typeof(IEstimateDetail));
                //_regionManager.RegisterViewWithRegion("MainRegion", typeof(ManageTemplate));
                //_regionManager.RegisterViewWithRegion("MainRegion", typeof(EstimateDetails));
                //_regionManager.RegisterViewWithRegion("MainRegion", typeof(Dashboard));
            }
        }
    }
}
Microsoft.Practices.Prism.Modularity.ModuleInitializeException: An exception occurred while initializing module 'AdministrationModule'. 
    - The exception message was: An exception has occurred while trying to add a view to region 'MainRegion'. 
    - The most likely causing exception was was: 'System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) Cannot find a Resource with the Name/Key DashBoardTitleTextBoxtStyle [Line: 26 Position: 11]
Developer
Feb 21, 2013 at 7:08 PM
Hi,

Based on my understanding of your description, it seems you have a Module that uses a style contained in its own App.xaml file. If this is the case, the problem you are experiencing could be related to a known issue when defining resource dictionaries inside Modules in a Prism & Silverlight application. You can find more information about this known issue, as well as possible workarounds for it, in the following article:
On the other hand, if this is not related to the problem you are experiencing, it would be helpful if you could provide us with more information about where the style is being defined, where the view is and how the view is using the style, so that we can help you further with this.

I hope this helps,

Damian Cherubini
http://blogs.southworks.net/dcherubini