Integrating an external module not referenced in the WPF project.

Dec 2, 2009 at 4:13 AM
Edited Dec 2, 2009 at 4:14 AM

I'm trying to use a module that is not referenced as part of the project.

Here's my setup:

- WPF project

- Project holding the interface IJsonViewer (the WPF project has a reference to it)

- Project that holds the module JsonViewer (the WPF project does not have to reference to it) having a reference to the interface IJsonViewer and implementing it.


In the WPF project the bootstrapper loads the module from its path declared in the DirectoryModuleCatalog. Now how to I resolve its type?

this.Container.RegisterType<IJsonViewer, JsonViewer>()

is not valid since JsonViewer is unknown from the WPF project.

I have access to the module info through this.ModuleCatalog.Modules though. How should I proceed? For some reason I haven't found any hints in the documentation. Is this possible at all?

Thank you,


Dec 7, 2009 at 3:29 PM

Hi Eric,

As you said, it is not possible to register the type in the container without having a reference to the assembly that holds the JsonViewer. Therefore, from your WPF project you will not be able to register the type mapping, but you will be able to resolve this item. The following are the steps to follow to get this done:

  1. You need to load the module that does have a reference to the JsonViewer implementation (if I understand correctly the third one you enumerated).
  2. Register the type mapping in the container as you are, in the module’s Initialize method.
  3. In the WPF project module (the first one enumerated), resolve a JsonViewer instance from the container as follows:
    IJsonViewer jViewer = container.Resolve<IJsonViewer>();

As you explained this approach lets you decouple the module with the JsonViewer’s real implementation and other modules that consume it.

In the StockTrader RI that comes with Prism, you can see a similar approach. The MarketModule class registers the IMarketFeedService and the ObservablePosition class in the PositionModule uses it (through constructor injection).

Please let me know if this helps.

Damian Schenkelman

Dec 8, 2009 at 1:26 PM

Thank you Damian,

Yes, it is working! It's an amazing piece of software.