FileNotFoundException on trying to Instrument AspNetCore application
varkey98 opened this issue · comments
Bug Report
Symptom
Getting this error on trying to instrument AspNetCore application
PS C:\Users\varkeychan_jacob\dotnetserver\HttpServer\bin\Debug\net8.0> .\HttpServer.exe
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
crit: Microsoft.AspNetCore.Hosting.Diagnostics[11]
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper failed to execute. See the inner exception for more details.
---> System.IO.FileNotFoundException: Could not load file or assembly 'OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly.<InternalLoad>g____PInvoke|49_0(NativeAssemblyNameParts* __pAssemblyNameParts_native, ObjectHandleOnStack __requestingAssembly_native, StackCrawlMarkHandle __stackMark_native, Int32 __throwOnFileNotFound_native, ObjectHandleOnStack __assemblyLoadContext_native, ObjectHandleOnStack __retAssembly_native)
at System.Reflection.RuntimeAssembly.InternalLoad(NativeAssemblyNameParts* pAssemblyNameParts, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Boolean throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()
--- End of inner exception stack trace ---
Expected behavior
App gets instrumented
Runtime environment (please complete the following information):
- OpenTelemetry Automatic Instrumentation version: v1.2.0
- OS: Windows Server 2022 Datacenter 21H2
- .NET version: NET Framework 4.8.1, .NET Core 8.0.100
Additional context
Add any other context about the problem here.
Reproduce
Steps to reproduce the behavior:
- Proceed as per steps mentioned here: https://opentelemetry.io/docs/instrumentation/net/automatic/#windows-powershell
- On running .\MyApp.exe, it'll throw the above error
@varkey98, could you please create Minimal, Reproducible Example? It should include all steps used to build, copy files. Without this, it will be hard to reproduce.
Sure, please give me some time
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapPost("/hello", async delegate(HttpContext context)
{
HttpRequest request = context.Request;
StreamReader reader = new StreamReader(context.Request.Body, Encoding.UTF8);
string body = getRequestBody(context.Request.Body);
if (string.IsNullOrWhiteSpace(body))
{
await context.Response.Body.WriteAsync(Encoding.ASCII.GetBytes("Hello World!"));
}
else
{
await context.Response.Body.WriteAsync(Encoding.ASCII.GetBytes(body));
}
});
app.Run();
Please find my application code
It does not looks like steps to reproduce. It is just a code. Pleas provide exact steps similar to:
1..Execute dotnet build xxxx
in forlder.
2. Execute yyyyy
3. Execute zzzz to instrument application.
Etc.
SIG: no repro at this moment, can re-open if needed.