It's clear why it happens, but not clear why not to change the way SynchronizedLifetimeManager works.
The problem is here:
private void TryExit()
// Noop here - we don't hold the lock and that's ok.
If we are debudding with the option "break at throw" turned on then we break at EVERY type registration . It's pain.
Why not do something like this:
private bool is_locked;
public override object GetValue()
if(value != null)
is_locked = true;
private void TryExit(object lockObj)
is_locked = false;
There's no exceptions now.