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"))
Micah
  • 111,873
  • 86
  • 233
  • 325

1 Answers1

4

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...

Neil Hewitt
  • 2,518
  • 18
  • 24