StructureMap.Microsoft.DependencyInjection icon indicating copy to clipboard operation
StructureMap.Microsoft.DependencyInjection copied to clipboard

Singletons are getting disposed

Open kvanover opened this issue 8 years ago • 2 comments

I have a problem with registered entries as singleton. If I add a registration as a singleton (with IDisposable as interface), these objects are getting disposed on request ending in aspnetcore, but still exists in the container on the next request, but disposed off course.

Is this normal? I would think if you register a singleton, It would not get disposed on request scope?

ex: container.Configure(x => x.For(serviceType).Use(implementationType).Singleton());

Thanks,

Koen

kvanover avatar Jan 10 '17 08:01 kvanover

combining singletone and idisposable is considered as a bad idea :)

valerysntx avatar Jan 12 '17 18:01 valerysntx

Hmm. I'll have a look. It sounds really weird that a singleton should be disposed when a nested container is disposed.

khellang avatar Jan 14 '17 15:01 khellang