Hi Pete,
Sorry I didn't get back to you yesterday, but I see that you ended up solving your problem ok.
Sorry about the compile errors, but what I had done when I posted was a copy/paste of some of my code, but I changed it slightly and screwed up the change. I don't typically use foreach and yet for some reason (and I don't remember why ... probably because you used a foreach), I changed my simple "for" to a "foreach" when I posted it here and inadvertently got it wrong. Sorry. What it should have been is this:
private void frmPluginTest_Load(object sender, EventArgs e)
{
string[] dllFilenames = Directory.GetFiles(@"P:\PJKPlugin\TabPagePlugins","TabPage*.dll");
foreach (string filename in dllFilenames)
{
try
{
Assembly asm = Assembly.LoadFrom(filename);
Type[] typesInAssembly = asm.GetTypes();
for (int i=0; i < typesInAssembly.Length; i++)
{
if (typesInAssembly[i].IsSubClassOf.GetInterface(typeof(PJKPlugins.ICMSTabPage)))
{
PJKTabPage oTP = (PJKTabPage)asm.CreateInstance(typesInAssembly[i].Namespace + "." + typesInAssembly[i].Name);
this.PluginTabControl.Controls.Add(oTP);
}
}
}
catch
{
}
}
}
~~Bonnie
>Hi Bonny, finally got around to trying your code but it doesn't compile, IsSubclass is a method which requires a Type as an argument, I tried various ways to get it working but it wont compile, thanks again