You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.
If you register a specific instance of an object during Bootstrapper's ConfigureRequestContainer it will dispose of said instance when a new NancyHost is created using that bootstrapper and on subsequent requests going through that host.
Steps to Reproduce
publicclassUnmanagedClass:IDisposable{booldisposed;publicUnmanagedClass(){disposed=false;
Console.WriteLine("Created");}publicvoidDispose(){if(disposed){
Console.WriteLine("Double dispose");}else{
Console.WriteLine("Fist dispose");disposed=true;}}publicstringGetSomeData(){if(disposed){return"I was disposed!";}else{return"Here, some data";}}}classCustomBootstrapper:DefaultNancyBootstrapper{privatereadonlyUnmanagedClassdependency;publicCustomBootstrapper(UnmanagedClassinDep):base(){dependency=inDep;}protectedoverridevoidConfigureRequestContainer(TinyIoCContainercontainer,NancyContextcontext){base.ConfigureRequestContainer(container, context);// Now this specific instance of UnmanagedClass will be passed to modules
container.Register(dependency);}}publicclassUserModule:NancyModule{// A module doesnt even need to depend on a UnmanagedClasspublicUserModule(){
Get(@"/",_ =>"l");}}classProgram{staticvoidMain(string[]args){// an instance of managed class created "somewhere else"vardependencyInstance=new UnmanagedClass();// Host is made from a bootstrapper, immediately disposesvarbootstrapper=new CustomBootstrapper(dependencyInstance);varhost=new NancyHost(bootstrapper,new Uri("http://localhost:6999"));// dependencyInstance is disposed
host.Start();
Console.ReadKey();// and regular disposes here}}
Just prints out "Create" and immediately "First dispose"
Nancy version: 2.0.0
Nancy host:
Nancy.Hosting.Self
Other Nancy packages and versions: master in this repo
Environment (Operating system, version and so on):
.NET Framework version: Core 2.0 and Framework 4.6.1, but should apply to everything
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
If you register a specific instance of an object during Bootstrapper's ConfigureRequestContainer it will dispose of said instance when a new NancyHost is created using that bootstrapper and on subsequent requests going through that host.
Steps to Reproduce
Just prints out "Create" and immediately "First dispose"
The text was updated successfully, but these errors were encountered: