mercredi 25 mars 2015

Loading plugins dynamically using reflection

Here is my code snippet



string pluginDirectory = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory, "Bin");

var pluginAssemblies =
from file in new DirectoryInfo(pluginDirectory).GetFiles()
where file.Extension.ToLower() == ".dll"
select Assembly.LoadFile(file.FullName);

var pluginTypes =
from assembly in pluginAssemblies
from type in assembly.GetExportedTypes()
where typeof(IPaymentProvider).IsAssignableFrom(type)
where !type.IsAbstract
where !type.IsGenericTypeDefinition
select type;


I get null in the pluginTypes all the time. What am I doing wrong?






Aucun commentaire:

Enregistrer un commentaire