Skip to content

Consider removing Microsoft.Extensions.* from additional deps #4155

Open
@RassK

Description

@RassK

Bug Report

Additional deps can also affect user libs, so sometimes Microsoft.Extensions.* dependency tree is misloaded because it's partially rolled forward and partially double loaded (using dependency load context).

Image

Method not found: 'Microsoft.Extensions.Logging.ILoggingBuilder Microsoft.Extensions.Logging.LoggingBuilderExtensions.AddConfiguration(Microsoft.Extensions.Logging.ILoggingBuilder, Microsoft.Extensions.Configuration.IConfiguration)'.

Setup

ASP.NET Core app with .NET 8 framework.

(EntityFramework just takes loads of Micrososft.Extensions.* deps, so issues pop up easily)
Microsoft.EntityFrameworkCore v8.0.14
Microsoft.EntityFrameworkCore.Design v8.0.14
Microsoft.EntityFrameworkCore.Sqlite v8.0.14

OpenTelemetry .NET AutoInstrumentation: latest main

Workaround

Seems if we remove Microsoft.Extensions.* from additional deps and instead let loader to load all of those to dependency load context, the application is able to work and function normally and produce traces

Drawback

OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper fails to load, so no logs. Don't know a fix yet for that.

System.InvalidOperationException: Startup assembly OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper failed to execute. See the inner exception for more details.
---> System.MissingMethodException: Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.ConfigureLogging(Microsoft.AspNetCore.Hosting.IWebHostBuilder, System.Action`1<Microsoft.Extensions.Logging.ILoggingBuilder>)'.
at OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper.BootstrapperHostingStartup.Configure(IWebHostBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()
--- End of inner exception stack trace ---

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions