EntLib6 (Logging/ExceptionHandling) and WCF service hosted in IIS using AppFabric

Topics: Exception Handling Application Block, Logging Application Block
May 9, 2013 at 6:14 PM
Have had some trouble getting WCF services hosted in IIS and using AppFabric to be able to use the logging and exception handling application blocks.

Every now and then see this error in the Application Event log, but sometimes see nothing. Not sure it's related, but it appears when making changes to logging configuration (which is all declarative). It seems related to the auto-start feature of server AppFabric. Never saw this error until switching to the EntLib6 version. Running previously on version 5 of entlib.

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