C# InvalidOperationException: Unable to resolve service for type 'AutoMapper.Mapper'


報錯信息:

InvalidOperationException: Unable to resolve service for type 'AutoMapper.Mapper'

while attempting to activate 'BLL.Implementation.Report'.

檢查后發現名稱寫錯了

錯誤:

private readonly Mapper _mapper;

正確的是:

private readonly IMapper _mapper;

總結

出現這類錯誤注意檢查接口與實現類名稱

 

另外一種情況是沒有在startup類的ConfigureServices中注入automapper依賴

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM