C
C#17mo ago
.tree

❔ Circular dependency between projects

I migrated an old project to .NET 6 from .Net Framework. The application is a REST service running on a windows service. In the old version, both of those were in a single project. With .NET 6 however I decided to split them into a Web API project for the REST service and a Windows Worker Service project for the Windows service, as that seems to be the best practice. Now I have the issue of the REST project depending on the Windows Service project and vice versa. How do I deal with this?
2 Replies
Anton
Anton17mo ago
decouple them by defining a third project with abstractions, aka interfaces, and use loose coupling by depending on these interfaces in the two projects for example, if you have a service in A which B depends on, make an interface for that service and put it into the abstractions project. put the implementation into A project. depend on the interface in the B project.
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.