The easiest way is not to put all the application DLLs into the webapp\bin which is watched by IIS. You can utilize dynamic DLL load from a custom location using the AppDomain.AssemblyResolve Event.
For that you will need to register an HttpModule
in the web.config
</configuration>
</system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="CAssemblyResolveHttpModule"/>
<add name="CAssemblyResolveHttpModule"
type="CAssemblyResolveHttpModule"/>
</modules>
</system.webServer>
</configuration>
And an implementation for it:
public class CAssemblyResolveHttpModule : IHttpModule
{
public void Init(System.Web.HttpApplication iContext)
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}
private Assembly CurrentDomain_AssemblyResolve(
object iSender,
ResolveEventArgs iArgs)
{
return Assembly.LoadFrom(...);
}
}
Besides that you can prevent IIS from recycling the ASP.NET Application when bin folder changes via IIS settings:
Can I prevent IIS from recycling if /bin changes
It is simple:
In the Application Pool > Advanced Settings > Recycling
section, set the Disable Recyling for Configuation Changes
to True
.
If you move most of your DLLs out of the app bin folder the IIS application pool recycling will take not more than a few moments. In order to catch up another new DLL version you will need to recycle the application pool.
If you still wish to avoid app pool recycling altogether you can use the strategy of a custom app domain pool. Here you can get code samples: Create custom AppDomain and add assemblies to it