I have an application that uses plugins that are controlled through an interface. Then I dynamically load the plugin classes and pass them to the interface to work with them.
I have the following line of code, suppose IPlugin is my interface.
IPlugin _plugin = (IPlugin)Activator.CreateInstance(oInfo.Assembly, oInfo.FullyQualifiedName)
It should be pretty simple, instantiate and pass it to the interface. I know that the assembly and fully qualified name values ββare correct, but I get the following exception.
Exception = System.InvalidCastException: cannot cast object of type "System.Runtime.Remoting.ObjectHandle print" MyNamespace.Components.Integration.IPlugin. in MyNamespace.Components.Integration.PluginProxy..ctor (Int32 InstanceId)
Any ideas what might cause this?
reflection c # interface
Mitchel sellers
source share