-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
after autoinstrumention FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions #2269
Comments
@soulmate1314,
|
AutoInstrumetnation version: https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v0.6.0-beta.2 No version of ‘Microsoft.Extensions.DependencyInjection.Abstractions’ is referenced in the project Then I use a simple web application developed based on dotnet 6.0 and asp. net to access the instrument on the same centos7 machine, and there is no exception |
@soulmate1314, could you please share with us what was the issue? |
localhost:/home/Blog.Core/.PublishFiles# . $home/.otel-dotnet-auto/instrument.sh File name: 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' Aborted |
Hello, could you please explain this bug |
@soulmate1314, you have decided to close the issue. I assume that you have solved it somehow. Can you share the steps? If you need any help, could you please be more descriptive? Pleas create Minimal, Reproducible Example. |
hey @soulmate1314 👋
I do not follow. Can you please share with us a minimal application that you are trying to instrument? Is |
AutoInstrumetnation version: [v0.6.0-beta.2] Sorry, it may have been accidentally closed.
3.Then I encountered these errors `Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. File name: 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' $(String[] args) in /home/Blog.Core/Blog.Core.Api/Program.cs:line 26 |
@soulmate1314 the information you have provided is not enough the reproduce the bug. PTAL #2269 (comment) |
@soulmate1314 if getting a minimal repro is hard, could you please capture the |
@pjanotti @pellared @Kielek environmentAutoInstrumetnation version: [v0.6.0-beta.2] Bug recurrence process#go to the home directory The execution commands and parameters are shown in the figure belowThe following is the corehost logshttps://github.com/soulmate1314/issue-logs/blob/main/corehost_verbose_tracing.log |
I was able to reproduce issue on docker image. Dockerfile FROM centos:centos7.9.2009
RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum update -y \
&& yum -y install git \
# unzip needed for our otel script
&& yum -y install unzip \
&& yum -y install dotnet-sdk-6.0
# Download the bash script
RUN curl -sSfL https://raw.githubusercontent.com/open-telemetry/opentelemetry-dotnet-instrumentation/v0.6.0/otel-dotnet-auto-install.sh -O
# Install core files
RUN sh ./otel-dotnet-auto-install.sh
RUN git clone https://github.com/anjoy8/Blog.Core \
&& cd Blog.Core \
&& chmod u=rwx Blog.Core.Publish.Linux.sh \
&& ./Blog.Core.Publish.Linux.sh then I have executed following methods in interactive commands: # Log4Net.cofnig needed to execute /home/Blog.Core/Blog.Core.Api/bin/Debug/.PublishFiles/Blog.Core.Api without instrumentation
touch /home/Blog.Core/Blog.Core.Api/bin/Debug/.PublishFiles/Log4Net.config
. $HOME/.otel-dotnet-auto/instrument.sh
OTEL_SERVICE_NAME=servicepatrol-configservice OTEL_TRACES_EXPORTER=otlp OTEL_METRICS_EXPORTER=otlp OTEL_LOGS_EXPORTER=otlp OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317/ OTEL_EXPORTER_OTLP_PROTOCOL=grpc OTEL_RESOURCE_ATTRIBUTES=service.name=servicepatrol-configservice COREHOST_TRACE=1 COREHOST_TRACEFILE=/root/corehost_verbose_tracing.log /home/Blog.Core/Blog.Core.Api/bin/Debug/.PublishFiles/Blog.Core.Api It leads to
The reason: From my first comment:
Your answer:
For sure. You have some indirect reference to this library. What you can do is to add direct reference to |
@Kielek Thank you for your patient help. I did solve that exception according to your method, but I encountered a new problem, which is also an exception that the package could not find. What is the root cause of this problem? Is there a version conflict between the project package and the openteletry package? |
Exactly, all of them should be solved in the same way. |
(sorry, I wrote this comment yesteday, after seeing @soulmate1314 response at #2269 (comment) - now it will be a bit out of order - EDIT: I was able to try with Piotr's repro and my suggestion below doesn't have any effect) Thanks @soulmate1314, at first glance, it is looking like the issue is due to your app allowing only minor version roll-forward and a recent change intended to reduce the shared store size. Anyway, I hope to take a deeper look tomorrow, |
As @Kielek noticed there is an indirect reference to "Autofac.Extensions.DependencyInjection/8.0.0": {
"type": "package",
"dependencies": {
"Autofac": "6.4.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0"
}, This causes the assembly to be added to the bin folder of the application. The AdditionalDeps bumps it up to version 7.0.0. However, since the assembly is in the folder of the application, version 6.0.0 gets added to the list of trusted assemblies.
Later when the runtime later checks the version the error is raised. As mentioned this will be easy to fix via a NuGet package with our dependencies. That said I still want to look if it is possible to reasonably work around the problem. |
@soulmate1314 a temporary workaround will be to add the following NuGet packages to your project: <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" /> This works because the AdditionalDeps are bringing version 7.0.0 of the "Microsoft.Extensions.*" assemblies in order to support Logging. These two packages should be all that you need to cover it. |
@soulmate1314 Please close the issue if we helped you and answered all your questions 😉 |
@pjanotti Thank you for your patient help. I will try it according to your method. |
The program based on dotnet 6.0 can be started normally without access. The following exception is reported after access
localhost:/home/Blog.Core/.PublishFiles# . /root/.otel-dotnet-auto/instrument.sh
localhost:/home/Blog.Core/.PublishFiles# OTEL_SERVICE_NAME=servicepatrol-configservice OTEL_TRACES_EXPORTER=otlp OTEL_METRICS_EXPORTER=otlp OTEL_LOGS_EXPORTER=otlp OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 OTEL_EXPORTER_OTLP_PROTOCOL=grpc OTEL_RESOURCE_ATTRIBUTES=service.name=servicepatrol-configservice ./Blog.Core.Api
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
$(String[] args) in /home/Blog.Core/Blog.Core.Api/Program.cs:line 26at Microsoft.AspNetCore.Builder.WebApplicationBuilder..ctor(WebApplicationOptions options, Action`1 configureDefaults)
at Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder(String[] args)
at Program.
Aborted
The text was updated successfully, but these errors were encountered: