今天进行asp.net core开发的时候突然报错:
InvalidOperationExceptionUnable to resolve service for type 'AutoMapper.Mapper' while attempting to activate
这个问题导致的原因有几个,所以,直接的解决办法:
1.看看引用依赖项是否已经添加
2.在Startup.cs找到ConfigureServices方法内添加对应的服务:如services.AddAutoMapper();
3. 检查控制器Controller代码
public xxxController(HomeContext context, IHostingEnvironment _host, IMapper _mapper) { db = context; this.host = _host; mapper = _mapper; }
IMapper记得别写错,写成Mapper也会报错!
以上就是【asp.net core Unable to resolve service for type * while attempting to activate】的全部内容了,欢迎留言评论进行交流!