David Smith

David Smith

  • NA
  • 2k
  • 0

Verify Assembly implements interface

Oct 31 2016 5:48 AM

How to verify c# Assembly Implements a Certain Interface?

private static void LoadPlugins(IList<Assembly> assemblies)
{
DirectoryInfo dInfo = new DirectoryInfo(GetExtensionsDirectory());
FileInfo[] files = dInfo.GetFiles("*.dll");

if (null != files)
{
foreach (FileInfo file in files)
{
string[] fileArray = file.Name.Split('.');

if (fileArray != null)

{ // I want to verify if assembly implements a IPlugin interface before adding assemebly.

assemblies.Add(Assembly.Load(fileArray[0]));

}

}
}
}


Answers (1)