Hi,
I have an issue with a service exported as Shared :
[Export(typeof(IContextRequirementSelection))]
[ExportMetadata("ContextName", "Company")]
[PartCreationPolicy(CreationPolicy.Shared)]
This service is located in a XAP which is dynamically loaded once the user login.
In the main application, I have a usercontrol which has an import on all the service implementing IContextRequirementSelection
[ImportMany(AllowRecomposition = true)]
public IEnumerable<Lazy<IContextRequirementSelection, IContextRequirementMetadata>> ContextSelections;
Once the user login, the collection gets populated and when I access to the element with the metadata "Company", the instance is created.
Now, an action in my application load another XAP which also need to use this shared service.
I use the same syntaxe as the one above and MEF gives me a NEW instance of the service with the metadata "Company"
After reading a little bit on this subject, the only possibility seems to be if a new MEF container is created by the application.
To try to confirm it, I changed for the test purpose the references in my application to add a reference to the assembly hosting the exported service.
Then, when I run the application, both usercontrols share the same instance as expected !
Is this a problem in cocktail or devforce ?
regards,