Not trying to justify a possible bug, but types that implement
IDisposable should
- never throw an exception on the dispose call
- Unregister from finalize if they added a finalizer
- handle gracefully multiple calls to dispose
That's why I always code my classes that implement this contract as
private volatile bool _disposed;
public void Dipose(){
if (_disposed) return;
.. dispose logic
_disposed = true;
}
For instance:
https://github.com/castleproject/castlezmq/blob/master/src/Castle.Zmq/Socket.cs
On Mon, Jun 30, 2014 at 10:49 AM, Xavier <[email protected]> wrote:
> 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.
--
Cheers,
hammett
http://www.d-collab.com/
http://www.hammettblog.com/
--
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.