Suppose I have 2 classes, Foo and Bar. Foo does not have (and cannot have) a relation to Bar.
However, I want a bar instance to stay alive, as long as it\'s foo instance
It's difficult to give suggestions without knowing exactly what you're trying to achieve, or what you mean by "alive". Normally you shouldn't need to worry about lifetime of managed objects: they "die" naturally when they're no longer referenced.
But to do what you appear to want, either your Foo
instance must reference the Bar
instance, or some other object must reference both in order to create the link. It could be a reference to a Bar
instance as a System.Object
, i.e. Foo
doesn't need to know about the Bar
Type.