This project has moved and is read-only. For the latest updates, please go here.

How to reset mef container to implement Logout for my silverlight app

Sep 14, 2012 at 9:00 PM

I am trying to implement logout functionality in my OOB(out of browser) Silverlight 5 Prism4.1 MEF project. Most my viewmodels are shared. How can implement this.

Container.ReleaseExports does not work on shared instances.

My post may look similar to "" but i did not get it.

I have seen similar post at "" which has no answer either.

Jan 29, 2013 at 5:05 AM

I'm having the same problem and need to "reset" the MEF container and clear out the shared parts.
This is a dealbreaker for using MEF for IoC if I cannot empty out the container. 

As Dimpu575 stated, ReleaseExports only works on non-shared instances.


PS: @Dimpu575 - Did you find a way to solve this issue yet? 

Jan 29, 2013 at 6:39 AM

Have you considered simply creating a whole new container and disposing the old one?



Jan 29, 2013 at 7:37 AM
Edited Jan 29, 2013 at 7:38 AM

Thanks - yes I did but I wasn't able to successfully do so because I'm getting the exception below when recreating the new one.

"The container has already been initialized either by another call to InitializeContainer or by someone causing the default container to be constructed. Ensure that InitializeContainer is one of the first things that happens in the application host to ensure that it is ready for the first composition."

PS: This happens upon this call (2nd execution of it)

_container = CompositionHost.Initialize( catalog );

Jan 29, 2013 at 1:44 PM


I ended up converting all my viewmodels as non shared and use some static methods and properties to share info btwn viewmodels. I dont know if that is right way but i had to move on :(