1

I am swapping out the standard Unity container in Prism 4 and run into a problem when my modules are initializing. Before I used to get an IUnityContainer injected and this then allowed me to register additional types from my module all well and good.

Now I am injecting an AutoFac.IContainer and it does not have the RegisterType methods i need. They are located in the ContainerBuilder class.

So the simple question is how to I register types into my main container from within my modules as they are loaded.

Thanks Craig

  • Possible duplicate of [Run-Time Registration With Autofac](http://stackoverflow.com/questions/6173566/run-time-registration-with-autofac) *which also discusses Prism*. – bentayloruk Jun 24 '11 at 11:46

1 Answers1

4

The standard Autofac way is building your modules as IModule classes, using builder.RegisterModule to load them into your container as part of the register process.

If you already have a container and need to add registrations to it, you use the ContainerBuilder again like this:

var cb = new ContainerBuilder();
cb.Register(...);
...

cb.Update(existingContainer);
Peter Lillevold
  • 33,668
  • 7
  • 97
  • 131