无法解析类型' Microsoft.ApplicationInsights.TelemetryClient'

时间:2016-06-20 13:02:06

标签: asp.net-core

我已将我的Web项目从RC1迁移到RC2,但我遇到此错误:

  

无法解析类型的服务   ' Microsoft.ApplicationInsights.TelemetryClient'在尝试时   启用   ' Microsoft.ApplicationInsights.AspNetCore.ExceptionTrackingMiddleware'

enter image description here

有什么想法吗?

1 个答案:

答案 0 :(得分:7)

您需要将"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();
}