understanding AssemblyCatalog

Topics: Prism v4 - WPF 4
Jun 28, 2011 at 12:59 PM
Edited Jun 28, 2011 at 1:00 PM


I have been trying to understand the Module aspect of prism. I was having couple of doubts regarding the same. 

Firstly, I believe that AssemblyCatalog can be used to discover Modules (which implement IModule) and other parts of that module (namely Views and ViewModels) in the concerned Assembly. If using MEF Container, attributes [Export] and [ModuleExport] on classes should be enough to help the container discover the Modules (and Views and ViewModels) and load it, if marked as "WhenAvailable" on the Module.cs. If this is true, then when the bootstrapper runs, I should see the Module being loaded and initialized. This is not happening in my solution and I have already created a discussion here

Secondly, what type of ModuleCatalog should be used for adding AssemblyCatalogs. In the "Modularity QuickStart Example, Mef", I see "ConfigurationModuleCatalog" being created, but the comment clearly says that it is required for configuring Modules through Configuration files. Also, we add AssemblyCatalogs  to AggregateCatalog , how does the ConfigurationModuleCatalog figure up.

There is another doubt regarding resolving dependencies. I am not able to use Container.GetExport<Shell>() in the CreateShell() method, whereas the ServiceLocator is able to do that. There are other things that work with ServiceLocator but not with Container.GetExport<>(). So should the ServiceLocator be extensively used in place of Container.GetExport<>() (or [Import] for injection).

Lastly this is loosely related (not talking about the Framework here) to this post



Jun 28, 2011 at 3:44 PM

Hi Nirvan,

Regarding you first concern, we have provided an answer in the thread you've created.

As for your second concern, you don't need to create an instance of a specific module catalog to add AssemblyCatalogs; just adding them to the AggregateCatalog is enough for Prism to load your modules into the corresponding module catalog.

Finally, about your last question, you could try using the GetExportedValue method instead of the GetExport method.

You might find the Modularity Chapter in the Prism MSDN documentation, as well as the Modularity QuickStarts useful to dig deeper into this.

I hope you find this helpful.

Guido Leandro Maliandi

Jun 28, 2011 at 4:33 PM


AssemblyCatalog works the way I was understanding as is clear from your response.

I used GetExportedValue<Shell> to obtain a reference to the Shell and it works.

So I will close this discussion. Thanks for the reply.