Number of references to an object.
I am attempting to write a resource manager that will eventually release a resource when it is no longer being used.
Unfortunately, as the manager itself always keeps a reference to the resource object, even after no other code in the program refers to it, the garbage collector will not free it. Is there a way to find out how many references there are to an object instance, or barring that a set of classes in C# that are already implementing the behavior I'm looking for? It seems silly to write my own reference counting into the code when C# is already doing it for you.
Thanks for any help.