当前位置 : 主页 > 网络编程 > ASP >

asp.net-core – 无法解析“Microsoft.ApplicationInsights.TelemetryClient”类型的服务

来源:互联网 收集:自由互联 发布时间:2021-06-24
我已将我的Web项目从RC1迁移到RC2,但我遇到此错误: Unable to resolve service for type ‘Microsoft.ApplicationInsights.TelemetryClient’ while attempting to activate ‘Microsoft.ApplicationInsights.AspNetCore.ExceptionTra
我已将我的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();
}
网友评论