-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDisposable and UsingFactoryMethod #325
Comments
I can't think of why this is occurring, I suspect because a dependency has a decommission concern (i.e. IDisposable) during the resolve it gets tracked, and then a second time for the factory. I assume setting Can you debug Windsor to determine why it is attempting to track the component a second time (and throwing). We can go from there to determine a way forward. P.S. fixed that spelling mistake in 61807e4, thanks. |
@aaron-hammond - Please see 710e85c This test is passing for me I am going to close this issue out as I think it might be a misconfigured container. Please feel free to continue the discussion here and if we do turn up anything we can always open the issue again. |
Sorry just double checked and I was resolving the wrong thing. |
I changed the test case this and it is still passing: [Test]
public void Can_resolve_service_using_factory_that_implements_disposable()
{
var a = Container.Resolve<ISomeConnectionService>();
Assert.That(a, Is.Not.Null);
var b = Container.Resolve<FailoverDatabaseConnectionExecutor>();
Assert.That(b, Is.Not.Null);
} |
@aaron-hammond - If you post a full repro on Github using the latest version of Castle, I might be able to help you spot where you have gone wrong ... |
@Fir3pho3nixx Sure i can do that, i think the issue isn't in doing |
The actual error I've tracked down to
When an attempt is then made to register the factory; the track method in
I think this is due to the fact that it has child components that are implementing IDisposable. When the track method in the @jonorossi asked me to figure out why it was being added and tracked a second time but i ran out of time last night and haven't had a chance to update. |
After checking this out I have managed to replicate the issue. Apologies for closing prematurely. |
@Fir3pho3nixx no problem mate. The issue, i think, boils down to the dictionary in
having a key set to the resolved type
and then also setting the key to
They both get to that tracked point by having child dependencies that rely on IDisposable (i think). The reasons for that i'm unsure of as this is the first time i've looked under the hood so to speak and as i say i ran out of time looking at it.. |
@aaron-hammond - you are right. From what I can see, the TransientLifestyleManager is asking the LifecycledComponentsReleasePolicy to track the FailoverDatabaseConnectionExecutor twice. I think this is happen because of the following resolution cycle:
This is a tricky one. I will keep looking. |
@Fir3pho3nixx - agreed, i'm seeing the same. Becomes a bit of a rabbit hole for me after that but if i get a bit more time i'll have a dig at this too. |
@aaron-hammond sorry I have simply not had time to look at this, any progress from your side? |
@Fir3pho3nixx i spent i bit more time on this but then gave up. We just used an IHandler selector instead as a work around. See: https://stackoverflow.com/questions/46075494/castle-windsor-usingfactorymethod-with-lifestyletransient/46276146#46276146 |
I tried a bit more debugging tonight. I believe the code calling typed factory component activators are not honouring the @ALL - If anyone who has information on how this flows through to typed factory activators that would be handy! |
Everything I said before was wrong. I even added the horrible factory facility in my original example. I am so sorry. I am only starting to learn windsor internals(without help from the original authors). I know more now. Feel free to tell me off. Turns out transient burdens for disposables are being N+1 tracked between factory registrations and non factory registrations for transients when it comes to burdens. My smoking gun was this This code is not quite complete because I needed to invalidate some tests. Let me know what you think. |
@Fir3pho3nixx Don't feel bad. We've all been there! ❤️ |
Consider:
When attempting to inject ISomeConnectionService i receive the following error:
If i remove IDisposable from SomeConnectionService then i don't receive the error any more. Is this by design? Is it not possible to have an object implementing IDisposable in the dependency chain in conjunction with .UsingFactoryMethod? As a side note there is also a spelling mistake "regustration" in the message.
The text was updated successfully, but these errors were encountered: