0

We have an application built in a style of "Onion architecture". We have an exe-module which contains a bootstrapper and all Views (windows). The bootstrapper should configure the IoC-container properly with accordance to the current application. We know which implementors have to be the resolvers for the interfaces. So we want to make something like:

container.AddDependency(IDevice, typeof(SpecificDevice));

But when we make that static binding, our exe module should reference the whole bunch of dll's that contain business logic. That leads to the situation where Views know everything and can access everything they want. It feels completely wrong.

So what we are doing wrong?)

p.s. Actually, we use Unity as the IoC container.

EngineerSpock
  • 2,575
  • 4
  • 35
  • 57

1 Answers1

2

Your mistake is that the Composition Root, the executable that orchestrates all dependencies, also implements a bunch of abstractions.

Rather, have your views in a separate assembly that only references other assembiles containing abstractions. Then, bind implementations to abstractions in the Composition Root, the executable.

The CR is the only place that should be aware of all abstractions and all implementations.

Wiktor Zychla
  • 47,367
  • 6
  • 74
  • 106