4

I'll try to explain in the simple way.

I have a solution (c# 4.0) that contain 4 projects

  • Framework
  • DAL
  • Domain
  • WebApplication

So my question is:

Framework is the right place to configure my Unity IoC? I want to configure via code and not with xml, so Framework need to know reference of DAL but DAL already knows Framework.

All my projects will know Framework, so where i configure my IoC?

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
Gustavo Melo
  • 199
  • 5
  • 11

1 Answers1

4

Applications should be configured in the Composition Root, which is as close to the entry point as possible. In your case, that would be the WebApplication. That's the only project which should have a reference to Unity. None of the other projects should have any reference to Unity at all.

In the composition root, you should follow the Register Resolve Release pattern.

See also this answer - it talks about Ninject instead of Unity, but the concept (and hence the answer) is the same.

Community
  • 1
  • 1
Mark Seemann
  • 225,310
  • 48
  • 427
  • 736