This article is a mirror article of machine translation, please click here to jump to the original article.

View: 23713|Reply: 1

[Source] Autofac "Circular component dependency detected" error resolved

[Copy link]
Posted on 2019-11-19 11:10:28 | | | |
DependencyResolutionException: Circular component dependency detected: Dolphin.WebUI.Controllers.HomeController -> Dolphin.Service.AccountService -> Dolphin.Service.OrderService -> Dolphin.Service.OrderService.



Error scenario: Using the Autofac IOC framework PropertiesAutowired property injection, this error code is caused by two types referencing each other, so we must set the behavior to allow circular dependencies when using Autofac for property injection. The code is as follows




Just add this PropertyWiringOptions.AllowCircularDependencies to solve this error




Previous:docker container to access external host services
Next:Deliberately spending money to register, the resources to be spent are simply deceptive
 Landlord| Posted on 2019-11-20 10:43:12 |


AsImplementedInterfaces() is injected as an interface, injecting all the common interfaces of these classes as a service (except for freeing up resources)

A:IA

builder. RegisterType<A>(). AsImplementedInterfaces();When using IA, an instance of A will be returned, that is, its own instance will be injected
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com