M
Max
I made a class library which I want to load when something happens.
How can I load this library and then pass in a paramter?
I tried:
Assembly asm = Assembly.Load("mylibrary");
Type t = asm.GetType("MyClass");
Object obj = Activator.CreateInstance(t, new object[] {myargument});
and I get an exception:
Exception caught: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
How can I load this library and then pass in a paramter?
I tried:
Assembly asm = Assembly.Load("mylibrary");
Type t = asm.GetType("MyClass");
Object obj = Activator.CreateInstance(t, new object[] {myargument});
and I get an exception:
Exception caught: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)