I'm looking for a more efficient way to find a type in an Assembly that derives from a known specific type. Basically, I have a plugin architecture in my application, and for the longest time we've been doing this:
For Each t As Type In assem.GetTypes()
If t.BaseType Is pluginType Then
'Do Stuff here'
End If
Next
Some of the plugins have a large number of types and we're starting to see this take a few seconds. Is there any way I can just ask for all types that have a BaseType of "pluginType"?
EDIT: I over-simplified my code sample. I was using .GetExportedTypes() in my actual code. However, I alot of classes were marked as Public, so it wasn't helping too much. I combed through the projects and marked everything "Friend" except for the actual plugin class, and it still takes nearly the same amount of time to examine the assemblies. I cut maybe 100 ms off of 1.3 seconds (which is less than 10%). Is this just the minimum time I have to deal with? I'd also tried the Assembly Attribute suggestion and it still didn't yield much difference (maybe 100ms again). Is the rest of the time the overhead I have to pay to load assemblies dynamically?