MEF does not support AppDomain isolation, so unfortunately, even during recomposition, those assemblies that were previously loaded are still loaded into the main AppDomain application. There are two things in ASP.NET that you need to fight:
Any changes to physical files (e.g. .aspx, .cshtml, etc.) or any changes to configuration files (.config) or any changes to the \ bin directory will result in reuse of the application. This is due to two things: file monitoring of pages / configs and monitoring files in the \ bin directory (which is due to the fact that ASP.NET uses shadow copying of files by default - this is recommended).
Using MEF in another AppDomain will require a disgusting amount of cross-domain communication, either through serialization or MarshalByRef
, which I just don't think will ever be a pure implementation. You donβt know how you will run the instances of BuildProvider
used to dynamically compile your pages into another AppDomain.
I wonder if you think too much about it. Starting with IIS6, HTTP.SYS manages the routing of incoming requests to the corresponding website, this is handled at the kernel level. Even if the main application rebooted (due to many reasons why it could), the requests will not be dropped, it simply waits for the queue of a new workflow before sending the request. Of course, from the user's point of view, they may notice some simple expectation of a restart of a new application, but really, how often are you going to make these changes?
Many application development suffer from over-engineering. You can design for each scenario, but itβs really easier to maintain a system that is simple but extensible. In my opinion, the desire to do what you indicated will be classified as excessive. Keep it simple.
source share