.net 未能从程序集“OpenTelemetry,版本=1.0.0.0,区域性=中性”加载类型“System.ServiceProviderExtensions”

yacmzcpb  于 2022-11-19  发布在  .NET
关注(0)|答案(2)|浏览(163)

程序包引用

<PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.4.0-beta.2" />
    <PackageReference Include="OpenTelemetry.Exporter.Prometheus" Version="1.2.0-rc5"/>
    <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.8" />
    <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.8" />
    <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.8" />

程序.cs

builder.Services.AddOpenTelemetryMetrics(b =>
{
    b.AddPrometheusExporter();
    b.AddMeter(TelemetryConstants.MyAppSource);
    b.SetResourceBuilder(resource);
    b.AddHttpClientInstrumentation();
    b.AddAspNetCoreInstrumentation();
});

当我运行应用程序时,它给出以下错误
System.TypeLoadException: 'Could not load type 'System.ServiceProviderExtensions' from assembly 'OpenTelemetry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c'.'
位于app.UseOpenTelemetryPrometheusScrapingEndpoint();

gtlvzcf8

gtlvzcf81#

尝试将OpenTelemetry.Exporter.Prometheus的版本切换回1. 4. 0-alpha.2至少它解决了我的问题。

omqzjyyz

omqzjyyz2#

添加opentelemetry.exporter.prometheus.aspnetcore软件包后,错误消失。

相关问题