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

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?
 
M

Mattias Sjögren

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
 
S

skbergam

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top