I'm working on a component which executes provisional method of any interface registered with ioc, and execution moment depends on different triggers. It must be able to save actions to be performed to database, so I'm saving method name, type and list of parameters (serialized to BLOB) into database until needed.
When trigger occurs, I need to execute method on a instance of type. As I'm using dependency injection, I have interface name saved into database (in format "Namespace.IInterface, AssemblyName"
)
To run Resolve<IInterface>()
method on ioc container, I need instance of its Type
:
Assembly assembly = System.Reflection.Assembly.Load(assemblyName);
Type service = assembly.GetType(typeName);
object instance = IOCContainer.Resolve(service);
My questions are:
Type.Load(typeName)
but got null)
typeName
that you use includes assembly name(something like MyNamespace.MyType, MyAssembly version=1.0.0.0,publicKeyToken=12345etc
) then Type.Load(typeName)
will get your type but not null;If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With