Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help needed with Reflection
Message
From
31/08/2007 13:22:20
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01250136
Message ID:
01251775
Views:
25
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
         {
              // Not a valid assembly, move on
         }
    }
}
~~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
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform