1
Answer

Verify Assembly implements interface

David Smith

David Smith

8y
274
1

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)