Ensuring cleanup when hosted in IIS

Mar 20, 2014 at 6:29 PM
Using the lightweight composition version.
Successfully creating, discovering and initializing parts.
All is well, except in some cases, where IIS still has a lock on the part assembly, preventing subsequent rebuilds without restarting IIS - and sometimes even that doesn't seem to work.
Seems to happen most often when an exception has occurred somewhere in the application, though not always.
Happens both in a preproduction environment (no debugger attached) and in our development environments (using local IIS).
Code is in place to cleanup on application end.

Looking for advice on what more could be done to ensure the assemblies are unlocked so they don't cause a problem with rebuilding or publish.
And.... I guess I don't understand why this is behaving differently than Providers, which are also dynamically loaded but don't cause this locking issue?

Any feedback much appreciated!