How can I scan all assemblies located in the bin directory and retrieve all types implementing an interface?
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
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With