tags:

views:

42

answers:

2

How can I scan all assemblies located in the bin directory and retrieve all types implementing an interface?

+3  A: 

You can find them easily using Reflection and a LINQ query

var type = typeof(IRyuDice);
var types = AppDomain.CurrentDomain.GetAssemblies().ToList()
    .SelectMany(a => a.GetTypes())
    .Where(t => type.IsAssignableFrom(t));

AppDomain.CurrentDomain.GetAssemblies returns a System.Reflection.Assembly[] collection. Then you select all Types in that Assembly and check if your interface is used by that type.

http://msdn.microsoft.com/en-us/library/system.appdomain.getassemblies.aspx

hunter
+2  A: 

My answer might be too obvious but I'll give it a shot...

You need to take a look at DirectoryInfo to get every file (*.dll) of the directory and the use reflection in order to digg into them...

Does that answer your question or do you want to know the actual implementation?

sebastian