How to inject dependencies in WCF when the Composition Root is on the client

前端 未结 1 1681
-上瘾入骨i
-上瘾入骨i 2021-01-20 17:06

Before I start I must say that I maybe biting more than I can chew but I am in a desperate learning rampage and I need a lot of help.

I am coding an exercise taking

相关标签:
1条回答
  • 2021-01-20 17:38

    Every application has its own Composition Root. The WCF service is an application on its own, and will means it has its own Composition Root.

    Or let me put it differently, the clients shouldn't dictate how the service is going to build up its object graphs and it’s hard to imagine since the service will live in its own process and most often on a separate machine.

    This doesn't mean multiple applications (in the same solution for instance) can't share a part of the DI configuration, but the object graphs of the client and the service will probably even have little in common (they don’t share much of the same code base). You will see much more sharing of the configuration, when you're building both a WCF service and a Windows Service that use the same business layer, for instance. But even in that case, although they perhaps share a great part of the DI configuration, we'll still say that they have their own Composition Root.

    0 讨论(0)
提交回复
热议问题