Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- loop through assemblies
- loop through types in assembly
- // Filter out unwanted types
- if (!type.IsClass || type.IsNotPublic || type.IsAbstract )
- continue;
- // This successfully created the right object
- object o = Activator.CreateInstance(type);
- // This threw an Invalid Cast Exception or returned null for an "as" cast
- // even though the object implemented IPlugin
- IPlugin i = (IPlugin) o;
- using System.Runtime.Remoting;
- ObjectHandle oh = Activator.CreateInstance(assembly.FullName, type.FullName);
- // This worked as I intended
- IPlugin i = (IPlugin) oh.Unwrap();
- i.DoStuff();
- IPluginModule pluginModule = (IPluginModule)Activator.CreateInstance(curType);
- Activator.CreateInstance(type, true);
Add Comment
Please, Sign In to add comment