None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type '***'
can be invoked with the available services and parameters:
Cannot resolve parameter '***' of constructor 'Void .ctor(***)'.
- DependencyRegistrar注册
builder.RegisterType<***Service>().As<I***Service>().InstancePerLifetimeScope();
- 构造函数注入
必须注入接口,非实现
- 接口必须有实现
本文探讨了使用 Autofac 进行依赖注入时遇到的问题,特别是无法解析特定构造函数参数的情况。文中提供了具体的代码示例,展示了如何注册服务及在何处出现问题,并强调了必须通过接口而非其实现进行依赖注入的重要性。
503

被折叠的 条评论
为什么被折叠?



