the1mason
typeof(T).IsAssignableFrom does not work as I expected
There is a method in a generic class
PluginLoader<TPlugin> : IPluginLoader<TPlugin>
:
There is also an interface IWebPlugin
with implementation Plugin1
This method is called with an assembly, containing Plugin1
and tries to create an instance of it. It worked before I made PluginLoader generic, but now typeof(TPlugin).IsAssignableFrom(t)
returns false.
Plugin1.GetInterface("IWebPlugin")
returnsIWebPlugin
, typeof(TPlugin
gets IWebPlugin
too, but the original condition fails nevertheless.
Here's my result of playing with the debugger
Why if Plugin1 implements IWebPlugin and typeof(TPlugin) is IWebPlugin, Plugin1 is not assignable from IWebPlugin?11 replies