There are two steps to this:
AppDomain.CurrentDomain.GetAssemblies() provides you with all the assemblies uploaded to the current application domain.- The
Assembly class provides the GetTypes() method to retrieve all types inside this particular assembly.
Therefore, your code might look like this:
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type t in a.GetTypes()) {
To search for specific types (for example, implementing this interface, inheriting from a common ancestor or something else), you will have to filter the results. In case you need to do this in several places of the application, it is useful to create a helper class that provides various parameters. For example, I used to apply namespace prefix filters, interface implementation filters, and inheritance filters.
See MSDN here and here for detailed documentation.
Ondrej Tucny Jan 14 '11 at 15:09 2011-01-14 15:09
source share