I'm using NancyHost for self hosting. But whenever I try to Stop or Dispose the host, I get these two exceptions:
mscorlib: Cannot access a disposed object.
Object name: 'listener'.
at System.Net.ListenerAsyncResult.GetContext () [0x0001c] in <748af814b14a45f7803e4fe5c9300d51>:0
at System.Net.HttpListener.EndGetContext (System.IAsyncResult asyncResult) [0x00099] in <748af814b14a45f7803e4fe5c9300d51>:0
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <52405d1838e24bc5b300f5ebeee9f7c4>:0
--- End of stack trace from previous location where exception was thrown ---
at Nancy.Hosting.Self.NancyHost+<>c__DisplayClass14_0.<Start>b__1 (System.Threading.Tasks.Task`1[TResult] contextTask) [0x00087] in <5e6fd4328ff54d50a87c10c9ee6cd54a>:0
mscorlib: Cannot access a disposed object.
Object name: 'listener'.
at System.Net.ListenerAsyncResult.GetContext () [0x0001c] in <748af814b14a45f7803e4fe5c9300d51>:0
at System.Net.HttpListener.EndGetContext (System.IAsyncResult asyncResult) [0x00099] in <748af814b14a45f7803e4fe5c9300d51>:0
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <52405d1838e24bc5b300f5ebeee9f7c4>:0
--- End of stack trace from previous location where exception was thrown ---
at Nancy.Hosting.Self.NancyHost+<>c__DisplayClass14_0.<Start>b__1 (System.Threading.Tasks.Task`1[TResult] contextTask) [0x00087] in <5e6fd4328ff54d50a87c10c9ee6cd54a>:0
Steps to Reproduce
The host function does this:
Task.Run(() =>
{
_host = new NancyHost(new HostConfiguration
{
UnhandledExceptionCallback = ExceptionHandler
}, new Uri($"http://localhost:{port}"), new Uri($"http://127.0.0.1:{port}"));
_host.Start();
EmitSignal(nameof(OnStart)); // to notify the rest of code
});
System Configuration
Nancy version: v2.0.0
Nancy host
[x] Nancy.Hosting.Self
Environment (Operating system, version and so on): Windows 10 x64
Description
I'm using NancyHost for self hosting. But whenever I try to
Stop
orDispose
the host, I get these two exceptions:Steps to Reproduce
The host function does this:
System Configuration