Hi, This reminded me of my own problem with typed factories and component disposal, which I never had the time to report...
In my case, the dependencies between components (a minimal setup that reproduced the problem) were: (root) -> IC1Factory (typed factory of IC1, transient, with Release method) C1 (implementation of IC1, transient, IDisposable) -> ISS SS (implementation of ISS, singleton, IDisposable) -> IC2Factory (typed factory of IC2, transient, IDisposable) C2 (implementation of IC2, transient, IDisposable) After a sequence of calls: 1) resolve IC1Factory from the container 2) obtain C1 from IC1Factory (which triggers creation of SS as a dependency of C1 and creation of IC2Factory as a dependency of SS) 3) return IC1Factory to the container (triggers disposal of C1) 4) resolve ISS from the container (returns the previously created SS singleton) 5) call a method on SS (through ISS) which tries to obtain an IC2 from its IC2Factory the last step results in an ObjectDisposedException coming from the TypedFactoryInterceptor attached to IC2Factory. Not sure if the underlying issue is the same or related to Xavier's problem, but it certainly feels like some components are disposed prematurely when using typed factories (and then disposed for the second time when they really should be disposed). If I find the time, I'll try to provide some failing tests. Another observation: disposable typed factories seem to violate the third rule mentioned by hammett, i.e. subsequent calls to Dispose() result in ObjectDisposedExceptions. Regards, Jakub Bereżański On Tuesday, July 1, 2014 9:27:56 AM UTC+2, Xavier wrote: > I agree Hammett. But we want to be sure that during the application life > cycle, document, views, etc are closed correctly, looking for object > disposal, memory leak, etc. At first glance, if an object is disposed > multiple times, it is because of an implementation problem: that is what we > are looking for and that's how we found this strange behavior with Windsor. > > Le lundi 30 juin 2014 15:49:26 UTC+2, Xavier a écrit : >> >> Hi, >> I have an strange problem with an application and it's really annoying >> because I'm not able to reproduce it with a simple sample. I hope my >> explanation will be clear enough. >> >> To summarize: >> - we have a transient UI component created by a typed factory A >> - this component itself has a dependency with another typed factory B: in >> the constructor, it uses it directly to create a transient view model. >> - when disposed (through its typed factory A), this UI component uses its >> dependent typed factory B to release the VM. >> - the problem is that the VM is disposed twice? >> >> When I look at the call stack: >> 1) the first Dispose is called after the release interception from the >> typed factory B. This is expected. >> 2) the second one is called because the VM is listed as a dependency of >> the UI component? >> >> This last point is really surprising and wrong: if I look at the >> container during the application startup, this dependency is not listed in >> the component's model. >> So I tried to understand how Windsor could add this dependency and found >> it in the CreationContext.ExitResolutionContext() method: when the UI is >> created, the typed factory B is called for the VM resolution, and in the >> ExitResolutionContext() method Windsor adds a dependency with the VM into >> the UI. >> >> We use Windsor 3.2.1. >> >> Thank you for your help. >> Xavier >> >> >> -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/castle-project-users. For more options, visit https://groups.google.com/d/optout.
