WPF Prism - Manage Modules In Application

prism, wpf

Solution

Once an assembly is loaded into an `AppDomain`, it does not (cannot) get unloaded until the `AppDomain` is torn down....I guess that is your problem.

There's some techniques to get around that if you look on the net.....

Create An Additional AppDomain

Create an additional `AppDomain` which you can then load your assembly into....when you are finished you just call `Unload` to shutdown the `AppDomain` and this will release the assembly.

However the types you want to be accessible from the other `AppDomains` have to derive from `MarshalByRefObject` so that your object is remoteable....and calls from other AppDomains can be marshalled across.

- Using AppDomain in C# to dynamically load and unload dll

Load Assembly into a MemoryStream

A very interesting technique here....it loads the assembly into a `MemoryStream` first, then it gets .NET to load the Assembly from the `MemoryStream`...that means the "file" on disk, isn't locked.

http://social.msdn.microsoft.com/Forums/en-US/clr/thread/093c3606-e68e-46f4-98a1-f2396d3f88ca/

How do I implement .net plugins without using AppDomains?

Problem

Using Prism with WPF, I want to allow users to select from a repository which modules they'd like to use. Each module is essentially an add-on, and selecting a module to use would just move it into their 'Modules' folder of DLL to load. But, in trying to move DLLs around when the application is running, an error is thrown because the DLLs are in use at that moment. How can you get around this and allow users to Add/Remove modules at will?

Original source

Related problems