I have a few Windows 2008 R2 AppFabric always-running auto-start services deployed as per this article. The services vary in type, some are scheduled Quartz.NET job hosts, some are NServiceBus endpoints, and some are WCF web services. I run into issues with deployment where after publishing the service continues to use old DLLs. Once I stop the respective application pool and clear "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files" thew newly deployed DLLs are used. If I don't clear that directory and only restart the application pool, sometime I get the following error in the event log:
There was an error during processing of the managed application service auto-start for configuration path: 'MACHINE/WEBROOT/APPHOST/services/products/importing.retrieval'. The error message returned is: 'An initialization error occurred while trying to preload an application.
Exception: System.InvalidOperationException
Message: Well known object of type 'System.Web.Hosting.PreloadHost' already exists in this App Domain.
StackTrace: at System.Web.Hosting.HostingEnvironment.CreateWellKnownObjectInstance(String assemblyQualifiedName, Boolean failIfExists) at System.Web.Hosting.HostingEnvironment.CreateWellKnownObjectInstance(String assemblyQualifiedName, Boolean failIfExists) at System.Web.Hosting.ApplicationManager.CreateObjectInternal(String appId, Type type, IApplicationHost appHost, Boolean failIfExists, HostingEnvironmentParameters hostingParameters) at System.Web.Hosting.ProcessHost.PreloadApplicationIfRequired(String appId, IApplicationHost appHostParameter, HostingEnvironmentParameters hostingParameters, LockableAppDomainContext ac) at System.Web.Hosting.ProcessHost.<>c_DisplayClasse.b_c(Object o)'. The worker process will be marked unhealthy and be shutdown. The data field contains the error code.
The error code points to this article however that doesn't seem to apply.
Should I have the application pool restart as part of the web publishing pipeline?
What might help is understanding exactly what happens to temporary data and the application pool when web deploy is use.