views:

76

answers:

1

I'm trying to figure out how to register a type at run-time using unity. Any Suggestions?

Basically I want to be able to do this:

Container.
   RegisterType(Of IMyInterface)(
            Type.GetType("Fully Qualified Type Name"))
+2  A: 

Use the non-generic overloads of RegisterType.

IUnityContainer container = new UnityContainer();
container.RegisterType(typeof(IMyInterface), Type.GetType("FQTN"));

The non-generic version of the methods take a simple type instance and do reflection, so this should do what you want. Code in C# rather than VB, but you get the idea...

DotNetGuy