Jun 23, 2012 at 8:47 AM
Edited Jun 23, 2012 at 8:55 AM
|
Hi, perhaps this is by design but i just want to confirm the below:
For every GetInstance() that resolves a type which has a common lifetime scoped object (such as a UnitOfwork), when the scope ends if the UnifOfWork implements IDisposable, dispose is called for every time a service dependent on this was resolved during
the scope.
Is this correct? Is the reason it is called multiple times incase we are doing something exotic in our dispose method?
Thanks,
Chris
container.RegisterLifeTimeScope();
using (container.BeginLifetimeScope()){
var serviceA = container.GetInstance();
var serviceB = container.GetInstance();
var unitOfWork = container.GetInstance();
unitOfWork.Save();
}
|
|
Coordinator
Jun 23, 2012 at 10:06 PM
|
This discussion has been copied to a work item. Click
here to go to the work item and continue the discussion.
|
|
Coordinator
Jun 23, 2012 at 10:09 PM
|
I can confirm this is a bug.
Note that this shouldn't affect your application, since the contract of IDisposable states that an implementation should allows Dispose to be called multiple times, but this is nonetheless quite annoying and can decrease performance. Registration for disposal
happens at the wrong place in the code, which causes this bug. The bug will be fixed in the next release.
Thanks for taking the time to report this.
|
|
Coordinator
Jul 3, 2012 at 9:05 PM
|
I just published a new package of the
Simple Injector Lifetime Scoping Extensions NuGet package (version 1.4.3.12185) that fixes this bug.
|
|