MEF as dependency Injection shows View twice

Topics: Prism v4 - Silverlight 4
Jan 8, 2011 at 8:04 PM

Hi,

I am quite a beginner to Prism and have beein going through the Training Kit of Prism 4.0.  Since this is not a documentation issue I can't raise the issue in there but its actually a problem I have with Prism and can't figure it out the whole day.

If I go through the exercise 3 with the provided project, it all works fine. But if I create a new one and do the same thing, it doesnt behave correctly.

It should show "View from Module A Loaded" -> Module B initialized --> View from Module B loaded.

However I get "View from Module A Loaded" -> Module B initialized --> "View from Module A Loaded" + View from Module B loaded.

A pity I can't attach my solution here, does an expert know from top of the head what could have gone wrong? I went through every line of code and can't see it. Its very frustrating..

 

Many Thanks,

Jan 8, 2011 at 9:00 PM

In case someone else has this issue,  checkout ModuleA's flags.

[PartCreationPolicy(CreationPolicy.Shared)]

Unlike ModuleB it has to be shared, otherwise it shows up twice due two instantiation.

I think I was too tired and need a break. ;o)

 

Developer
Jan 10, 2011 at 1:33 PM

Hi,

Thank you for sharing your findings with the rest of the community.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

Jan 10, 2011 at 8:33 PM

No problem Guido. :)

Houman