MEF. How to empty the default container?

I am trying to perform an exit operation from my Silverlight client.

During the login process, MEF initializes the DefaultContainer with instances of single export classes that contain user information (such as a password).

Is there a way to reinitialize / reset / remove the MEF / DefaultContainer framework as if it had not been initialized?

I want to go to the login page again after the user has successfully completed the exit operation ...

+4
source share
1 answer

Unable to reinitialize the CompositionHost container. Once it has been initialized or created by default, it cannot be changed.

However, you can create an AggregateCatalog and use TypeCatalog with singleton as the only type and remove it from the collection when it is no longer needed.

This does not change the fact that after creating the β€œpart” of the MEF, it is available to satisfy any other [Import] that it needs.

From MSDN :

Parts created by the default container to populate the import will be saved using the Managed Extensibility Framework (MEF) until the application shuts down. Long-term applications should use ExportFactory <T> to manage the life cycles of their parts.
+1
source

All Articles