I have a .NET application (actually this can be a problem for any N-Tiered application) which has 3 separate components.

  • ClassLibrary
    • Has Cross Cutting Concerns like logging, authentication and IoC resolving.
    • Has static Utility classes for Encoding/Decoding, Encryption etc.
  • ThirdPartyApps
    • Has external library references like YouTube, Azure, AWS nuget packages and libraries.
    • References to ClassLibrary to use logging and static utility classes.
  • Background Application
    • Also references to Class Library.
    • Includes logic to utilize ThirdParty Apps, such as consuming YoutubeAPI

My problem in here, from Background Application, I do not want do direct reference to ThirdPartyApps. Because, I want ClassLibrary to resolve provider I want (from ThirdPartyApps).

But I cannot register ThirdPartyApps in ClassLibrary with Autofac (IoC container), because ClassLibrary already referenced by ThirdPartyApps, so it will create "Circular Dependency Error".

Seems like I am missing an implementation logic here, and would like to see what would be a possible way to resolve it.

I am thinking to create another component for dependency mapping, but I do not want to create unnecessary extra component for no reason (or maybe this will be the solution?).

Is there any wrong logic I am missing here?

有帮助吗?

解决方案

(or maybe this will be the solution?)"

Yes, go and create another component, of course. And that component is not unnecessary. If you don't want to create a "big ball of mud", where everything depends on everything else, you will be happy that you don't need to bind your existing ClassLibrary to the ThirdPartyApps component directly.

许可以下: CC-BY-SA归因
scroll top