When running IntegrationService with Hangfire as a WebApp an exception can happen during deployment via WebDeploy. The specific exception in question is System.ObjectDisposedException .
Full stacktrace:
System.ObjectDisposedException Cannot access a disposed object.
Object name: 'Scope was already disposed. This is most likely a bug in the calling code.'.
at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.GetScope(CreationContext context)
at Castle.MicroKernel.Lifestyle.ScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)
at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy) at Castle.MicroKernel.DefaultKernel.Resolve[T]()
at Vertica.Integration.Hangfire.Console.HangfirePerformContextProvider.get_Current()
at Vertica.Integration.Hangfire.Console.HangfireConsoleWriterInterceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Vertica.Integration.Domain.LiteServer.LiteServerImpl.Output(String message)
at Vertica.Integration.Domain.LiteServer.BackgroundServerHost.WaitForExit(TimeSpan timeout)
at Vertica.Integration.Domain.LiteServer.HouseKeeping.WaitForExit(BackgroundServerHost host)
at Vertica.Integration.Domain.LiteServer.HouseKeeping.Dispose()
at Vertica.Integration.Domain.LiteServer.LiteServerImpl.Dispose()
at Vertica.Integration.Domain.LiteServer.LiteServerHost.Handle(HostArguments args)
at Vertica.Integration.ApplicationContext.Execute(HostArguments args)
Full Setup:
app.UseIntegrationService(application => application
.Bootstrap()
.UseWebApi(webApi => webApi
.FromCurrentApp(app)
.HttpServer(httpServer => httpServer.Configure(owin =>
{
owin.App.UseHangfireDashboard("/hangfire", new DashboardOptions
{
Authorization = new[] { new HangfireAllowAllAuthorizationFilter() },
});
}))
.WithPortal()
.AddFromAssemblyOfThis<Startup>())
.UseHangfire(hangfire => hangfire
.AddToLiteServer()
.EnableConsole()
.Configuration(configuration => configuration
.UseSqlServerStorage(ConnectionString.FromName("IntegrationDb"), new
SqlServerStorageOptions
{
QueuePollInterval = TimeSpan.FromSeconds(15)
})
)
.WithServerOptions(serverOptions =>
{
serverOptions.WorkerCount = 2;
DynamicQueueFilter.Apply(serverOptions);
})
)
.UseLiteServer(liteServer => liteServer
.AddFromAssemblyOfThis<Startup>()
.OnStartup(startup => startup.RunMigrateTask()))
);
// Will run the LiteServer feature "in the background"
app.RunIntegrationService(nameof(LiteServerHost));
Reproduce:
- Deploy and run IntegrationService as a WebApp with WebDeploy using the above configuration.
- Ensure the website is running
- Deploy the WebApp again via WebDeploy
- Observe the exception on the Errors page
When running IntegrationService with Hangfire as a WebApp an exception can happen during deployment via WebDeploy. The specific exception in question is
System.ObjectDisposedException.Full stacktrace:
Full Setup:
Reproduce: