1

I develop Prism 6 application with multiple modules and I need to define an instance of IUnityContainer in the class of each module. For example:

[Module(ModuleName = "AuthorizationModule", OnDemand = false)]
public class AuthorizationModule : IModule
{
    IRegionManager _regionManager;
    private readonly IUnityContainer container;
    . . . . .
}

but there are no assembly references referensing to IUnityContainer in the module. Should I add a reference to "Prism.Unity 6.2.0" assembly or I can restrict by adding of reference to "Microsoft.Practices.Unity" assembly to get IUnityContainer available?

Dr.Doog
  • 197
  • 4
  • 14

3 Answers3

1

You don't have to add the Prism.Unity package since it mainly contains classes used by the Shell application. The only thing you would be missing out on is the Unity extension methods such as RegisterTypeForNavigation to make registering your views for navigation a little easier. SO feel free just to add your container packages.

0

you should add the reference to Microsoft.Practices.Unity.dll to use IUnityContainer.

If you do not use DependencyInjection, then there is no need to use IUnityContainer. However, you will lose all advantages of louse-coupling, unit-tesing, mocking without DI.

Community
  • 1
  • 1
StepUp
  • 36,391
  • 15
  • 88
  • 148
0

Use Nuget to add the Prism.Unity package to the module project(s) in your solution. That way, you can easily get a reference to the assemblies you need, and you can have your main DI container inject a reference to itself via the module constructor. Having the Prism.Unity package and its dependencies in your modules is more than likely something you will need anyway.

public ModuleA(IUnityContainer container) 
{ 
}
R. Richards
  • 24,603
  • 10
  • 64
  • 64