how to resolve a dependency between two tightly co

2019-08-24 13:23发布

suppose i have an interface called ITestService with it's paired implementation, lets call it DefaultTestService in Assembly "A". I register DefaultTestService class as ITestService service in Autofac container. On the other hand assembly "A" has a reference to assembly "B".now I want to resolve DefaultTestService through it's corresponding interface (ITestService) in assembly "B", for doing this first I have to add reference to assembly "A" so that I can access and pass ITestService to Resolve<T>() method.

circular dependency !

ok.we can solve it by assigning a key for a component and resolve it by key.but what if the dependency not registered by me (and a key not assigned to it)?

Any idea? thanks for you'r suggestion.

1条回答
Explosion°爆炸
2楼-- · 2019-08-24 14:03

If assembly A depends on B and both assemblies need ITestService, this interface must be defined in assembly B, or a third assembly that both A and B depend on.

查看更多
登录 后发表回答