Error with Auto-Start

I’m currently developing a document publishing application that uses Hangfire.
I publish updates using Visual Studio Publish menu (deployment using File System).

I noticed that after publishing an update, hangfire was not working anymore as there was 0 active servers (in dashboard).

I followed instructions from Making ASP.NET application always running and now I don’t face the 0 server issue anymore. But I have an error in windows logs regarding the Preload after publishing an update. I do not have this error when stopping and starting the app pool. I can access the application normally.

Can I do something to avoid the error? Should I just ignore it?

Here’s the details:

There was an error during processing of the managed application service auto-start for configuration path: 'MACHINE/WEBROOT/APPHOST/TestServer/wsPublication'. 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__DisplayClass11.<PreloadApplicationIfNotShuttingdown>b__f(Object o)'.  The worker process will be marked unhealthy and be shutdown.  The data field contains the error code.

I had the same problem. After publishing the site using Web Deploy, my app pool crashed with the same error, and my site went down (503). I restarted the app pool manually, and it seems to be running fine now. However, I would really prefer not to have to do that with every deployment!

Were you able to resolve this? I’m having the same issue. I don’t want to have to manually restart the app pool after every deployment either!

I’m having the same issue too!? Is there a resolution to this?


I managed to fix this issue in the end - see here: