If a service hosted with TopshelfRoleEntryPoint throws an unhandled exception, this can cause TopshelfRoleEntryPoint to throw an ObjectDisposedException, as follows.
Application: WaWorkerHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException
Stack:
at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean ByRef)
at Microsoft.Win32.Win32Native.SetEvent(Microsoft.Win32.SafeHandles.SafeWaitHandle)
at System.Threading.EventWaitHandle.Set()
at Topshelf.TopshelfRoleEntryPoint.OnStop()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StopRoleInternal()
at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<StopRole>b__4()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
If a service hosted with TopshelfRoleEntryPoint throws an unhandled exception, this can cause TopshelfRoleEntryPoint to throw an ObjectDisposedException, as follows.
Our best guess as to the erring line is https://github.com/Topshelf/Topshelf.Azure/blob/master/src/Topshelf.Azure/TopshelfRoleEntryPoint.cs#L126