Here’s what I am trying to do in the bootstrapper:
protected override void ConfigureContainer()
{
Assembly someAssembly = Assembly.LoadFile(@".\SomeServiceImplementationLib.dll");
Type someServiceImplementationType = someAssembly .GetType(@"SomeServiceImplementation");
Container.RegisterType<ISomeServiceType, someServiceImplementationType >(new ContainerControlledLifetimeManager());
base.ConfigureContainer();
}
This doesnt compile saying “Type or namespace name expected” for someServiceImplementationType. But its indeed a type isn’t it?
Basically I want to load a particular assembly only if certain conditions are met at startup and if its loaded I would like to register a service implementation from the loaded assembly with the unity container. Is there any way to do this at all?
You are confusing compile-type generics and run-time typing.
Generics are a compile-time thing, unless you do a little bit of reflection magic to new up a new generic instance with the type… but that isn’t necessary.
The Unity container has other extensions for RegisterType that are easy to use.
Instead, just call the non-generic form: