I am using Unity.WebAPI in my .net project to register and resolve dependencies. I have four projects, that are
i) interfaces
ii) UserService (Actual Implementation)
iii) ProductService (Actual Implementation)
iv) Web API Project which reference all above three, and also contains the unity configuration.
Now my userService and product service concrete classes are dependent on each other, so when i try to resolve them it gives me stack overflow error.
My code in unityConfig at web api project is as follows:
container.RegisterType<IUserService, UserService>(); //Userservice constructor injects IProductService
container.RegisterType<IProducService, ProductService>(); //ProductServices constructor injects IUserservice
I thought that creating separate Interface project would not cause circular dependency.
Looking forward.