Retrieving a collection of all instances of a certain type in thecurrent AppDomain

  • Thread starter Thread starter skbergam
  • Start date Start date
S

skbergam

Does anyone know if there is a way to retrieve a collection of all
instances of a certain type in the current AppDomain? I want to have
a function on my utility class with the following signature:

public static IEnumerable<T> GetAllInstances()

Does anyone know if this is possible?
 
Does anyone know if there is a way to retrieve a collection of all
instances of a certain type in the current AppDomain?

There's no general way to do that. It can be done from a debugger, but
not from your code (unless you write the class type and keep track of
all instances yourself).


Mattias
 
There's no general way to do that. It can be done from a debugger, but
not from your code (unless you write the classtypeand keep track ofallinstancesyourself).

Mattias

How does the debugger do it? Is there a debugger API?
 
Back
Top