无法解析类型 'Microsoft.AspNetCore.Hosting.IHostingEnvironment 的服务
Unable to resolve service for type 'Microsoft.AspNetCore.Hosting.IHostingEnvironment
我正在从 netcore2.2
升级到 netcore3.1
我有一行调用 services.AddApplicationInsightsTelemetry();
结果如下
System.InvalidOperationException:“尝试激活 'Microsoft.AspNetCore.Hosting.DefaultApplicationInsightsServiceConfigureOptions' 时无法解析类型 'Microsoft.AspNetCore.Hosting.IHostingEnvironment' 的服务。”
我知道这与一个持续存在的问题有关 (https://github.com/microsoft/ApplicationInsights-dotnet/issues/1869),但这并不能帮助我解决问题。
是否有已知的解决方法?
更新了所有内容,原来这是模拟 IHostingEnvironment 的测试
我正在从 netcore2.2
升级到 netcore3.1
我有一行调用 services.AddApplicationInsightsTelemetry();
结果如下
System.InvalidOperationException:“尝试激活 'Microsoft.AspNetCore.Hosting.DefaultApplicationInsightsServiceConfigureOptions' 时无法解析类型 'Microsoft.AspNetCore.Hosting.IHostingEnvironment' 的服务。”
我知道这与一个持续存在的问题有关 (https://github.com/microsoft/ApplicationInsights-dotnet/issues/1869),但这并不能帮助我解决问题。
是否有已知的解决方法?
更新了所有内容,原来这是模拟 IHostingEnvironment 的测试