Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve service for type 'Microsoft.ApplicationInsights.TelemetryClient'

Tags:

asp.net-core

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

Unable to resolve service for type 'Microsoft.ApplicationInsights.TelemetryClient' while attempting to activate 'Microsoft.ApplicationInsights.AspNetCore.ExceptionTrackingMiddleware'.

enter image description here

Any ideas?

like image 617
chemitaxis Avatar asked Jan 06 '23 20:01

chemitaxis


1 Answers

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();
}
like image 175
Tseng Avatar answered May 27 '23 21:05

Tseng