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

Unloading Extensions

Jul 8, 2009 at 2:43 PM

I am working with this framework and had a question. Is there a way to unload an extension? Please post an example.

Jul 10, 2009 at 3:16 PM

Unfortunately, you cannot unload an extension at the moment afaik. I have tried it myself and I didn't get anywhere. However, in my case, I could deceive the user into thinking he/she has unloaded an extension by just closing and removing the extension. It was still in memory but to the user, he/she unloaded it. On reloading it, I just reinitialize the one in memory and yeeeahh!!!

Jul 14, 2009 at 10:55 PM

As Osei said... Do you need to simple cease to make it available via MEF by removing it from teh container (doable) or do you need to unload it from memory.

The only way to unload code is via an AppDomain. You could potentially create an AppDomain and unload it yourself. This is part of the System.AddIn design but nothing like that is yet included in MEF.

Jul 18, 2009 at 11:09 AM

As Kathleen mentioned, MAF (System.Addin) allows unloading extensions. You could load an addin through MAF, and then add it to the container by using the ComposeExportedObject extension method which allows you to associate it wiht a contract. Once it is in the container it can be imported. If all references to the import are released, then the MAF add-in will unload.