Difficulty using DryIOC in Web form

27 Views Asked by At

I want use DryIoc container in web form, I use sample code : https://github.com/dadhi/DryIoc/blob/master/docs/DryIoc.Docs/ReuseAndScopes.md#reuse-and-scopes But every time I ask, I get a new instance from the container :

 var container = new Container(rules => rules.WithDefaultReuse(Reuse.Scoped));
            container.Register<ScopeService>();

            _serviceContainer = container;

            using (var scope = container.OpenScope())
            {
                var oSingleton = scope.Resolve<ScopeService>();
                Debug.WriteLine($"APPLICION SINGLETON : {oSingleton.ID}");

                var oSingleton2 = scope.Resolve<ScopeService>();
                Debug.WriteLine($"APPLICION SINGLETON2 : {oSingleton2.ID}");
            }

I describe my service in Singleton reuse, But I get a new instance from the container

0

There are 0 best solutions below