Jan 19, 2011 at 5:42 PM
Edited Jan 19, 2011 at 5:51 PM
In my Silverlight application, when a user logs in, MEF creates instances of views and viewmodels "on demand" when the user clicks on a button, for example. But some views and viewmodels are dynamically populated with data based on roles of the
logged user, and some variables related to this logged user.
I would like that MEF release that instances of views and viewmodels when the user do logout and recreates again on the demand when another user logs in. I tried to do as following:
void AuthenticationLoggedOut(object sender, System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationEventArgs e)
public static void ReleaseAllExports()
var allExports = new List<Export>();
var telaexports = CatalogoMef.GetContainer.GetExports<ITela>();
foreach (var telaexport in telaexports)
allExports.Add(telaexport.Value as Export);
var telaviewmodelexports = CatalogoMef.GetContainer.GetExports<ITelaViewModel>();
foreach (var telaviewmodelexport in telaviewmodelexports)
allExports.Add(telaviewmodelexport.Value as Export);
But when debugging, the "allExports" variable contains null references and it appears that is not working.
Is there a better way to do this?