如何解决在asp.net-core项目中无法解析Microsoft.ApplicationInsights.TelemetryClient类型服务的难题?
- 内容介绍
- 相关推荐
本文共计156个文字,预计阅读时间需要1分钟。
我已经将原文简化如下:
将Web项目从RC1迁移到RC2时,遇到错误:无法解析类型'Microsoft.ApplicationInsights.TelemetryClient'。尝试激活'Microsoft.ApplicationInsights.AspNetCore.ExceptionTracking'时出错。
我已将我的Web项目从RC1迁移到RC2,但我遇到此错误:Unable to resolve service for type
‘Microsoft.ApplicationInsights.TelemetryClient’ while attempting to
activate
‘Microsoft.ApplicationInsights.AspNetCore.ExceptionTrackingMiddleware’.
有任何想法吗?
您需要将“Microsoft.ApplicationInsights.AspNetCore”:“1.0.0-rc2-final”添加到您的project.json,并将其添加到您的Startup类:public void ConfigureServices(IServiceCollection services) { ... // Add framework services. services.AddApplicationInsightsTelemetry(Configuration); ... } public void Configure(IApplicationBuilder app) { ... app.UseApplicationInsightsRequestTelemetry(); app.UseApplicationInsightsExceptionTelemetry(); ... app.UseMvc(); }
本文共计156个文字,预计阅读时间需要1分钟。
我已经将原文简化如下:
将Web项目从RC1迁移到RC2时,遇到错误:无法解析类型'Microsoft.ApplicationInsights.TelemetryClient'。尝试激活'Microsoft.ApplicationInsights.AspNetCore.ExceptionTracking'时出错。
我已将我的Web项目从RC1迁移到RC2,但我遇到此错误:Unable to resolve service for type
‘Microsoft.ApplicationInsights.TelemetryClient’ while attempting to
activate
‘Microsoft.ApplicationInsights.AspNetCore.ExceptionTrackingMiddleware’.
有任何想法吗?
您需要将“Microsoft.ApplicationInsights.AspNetCore”:“1.0.0-rc2-final”添加到您的project.json,并将其添加到您的Startup类:public void ConfigureServices(IServiceCollection services) { ... // Add framework services. services.AddApplicationInsightsTelemetry(Configuration); ... } public void Configure(IApplicationBuilder app) { ... app.UseApplicationInsightsRequestTelemetry(); app.UseApplicationInsightsExceptionTelemetry(); ... app.UseMvc(); }

