无法解析类型为"Microsoft.ApplicationInsights.TelemetryClient"的服务 [英] Unable to resolve service for type 'Microsoft.ApplicationInsights.TelemetryClient'

查看:104
本文介绍了无法解析类型为"Microsoft.ApplicationInsights.TelemetryClient"的服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have migrate my Web project from RC1 to RC2, but I'm having this error:

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

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 类中:

You need to add "Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final" to your project.json and this to your Startup class:

public void ConfigureServices(IServiceCollection services)
{
    ...
    // Add framework services.
    services.AddApplicationInsightsTelemetry(Configuration);
    ...
}

public void Configure(IApplicationBuilder app)
{
        ...
        app.UseApplicationInsightsRequestTelemetry();
        app.UseApplicationInsightsExceptionTelemetry();

        ...
        app.UseMvc();
}

这篇关于无法解析类型为"Microsoft.ApplicationInsights.TelemetryClient"的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆