{"Code":500,"Description":null,"Msg":"Unable to resolve service for type 'IServices.IDrugListService' while attempting to activate 'dy.WebApi.Areas.ArRuleManager.DrugListManagerController'.","success":false,"Data":" at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)\r\n at lambda_method566(Closure , IServiceProvider , Object[] )\r\n at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass7_0.<CreateActivator>b__0(ControllerContext controllerContext)\r\n at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass6_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location ---\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)","PageCount":0,"Total":0}
时间: 2024-04-28 14:22:31 浏览: 184
根据你的问题,我猜测你可能遇到了一个关于 ASP.NET Core Web API 的问题,具体来说是一个依赖注入的问题,无法解析类型为 IServices.IDrugListService 的服务,这个错误似乎发生在 dy.WebApi.Areas.ArRuleManager.DrugListManagerController 控制器中。这个问题可能是由于您没有正确配置依赖注入容器,或者您的服务注册代码存在问题导致的。建议检查您的代码,并确保正确配置了依赖注入容器。
相关问题
System.InvalidOperationException:“Unable to resolve service for type 'Microsoft.AspNetCore.DataProtection.IDataProtectionProvider' while attempting to activate 'Microsoft.AspNetCore.Session.SessionMiddleware'.”
这个错误通常是由于在ASP.NET Core应用程序中未正确配置数据保护服务导致的。你需要在应用程序的Startup.cs文件中配置数据保护服务。例如,可以在ConfigureServices方法中添加以下代码:
```
services.AddDataProtection();
```
确保在添加之前,已添加了所需的依赖项。如果还是无法解决问题,请检查是否有其他配置可能影响了数据保护服务的正确配置。
core3.1 System.InvalidOperationException: Unable to resolve service for type报错如何解决
这个错误通常是由于依赖注入容器无法解析服务类型引起的。要解决这个问题,你可以检查以下几个方面:
1. 确保你已经正确地注册了服务类型和它们的实现。
2. 确保你的服务类型和它们的实现在同一个程序集中。
3. 确保你的服务类型和它们的实现都是公共的。
4. 确保你的服务类型和它们的实现都有默认的构造函数。
如果以上几个方面都没有问题,你可以尝试清除依赖注入容器的缓存并重新启动应用程序。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)