寫.NET Core遇到Unable to resolve service for type通常是忘記註冊物件給DI容器
Startup.cs的ConfigureServices(IServiceCollection services)加入以下這一行
//TagsHelper使用
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
錯誤訊息:
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor' while attempting to activate
沒有留言:
張貼留言