Skip to content

[BUG] APM agent not working on .NET 7 #1900

@christallire

Description

@christallire

APM Agent version

The version of the Elastic.Apm nuget package used
https://github.com/elastic/apm-agent-dotnet/releases/download/v1.16.0/ElasticApmAgent_1.16.0.zip

Environment

Operating system and version:
Ubuntu focal arm64v8

.NET Framework/Core name and version (e.g. .NET 4.6.1, NET Core 3.1.100) :
.NET 7

Application Target Framework(s) (e.g. net461, netcoreapp3.1):
net7.0

Describe the bug

# kubectl logs -f backoffice-657d64b495-n849r app
Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at StartupHook.InvokerLoaderMethod(Assembly loaderAssembly) in C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1727\apm-agent-dotnet\src\ElasticApmAgentStartupHook\StartupHook.cs:line 179
   at StartupHook.Initialize() in C:\Users\jenkins\workspace\net_apm-agent-dotnet-mbp_PR-1727\apm-agent-dotnet\src\ElasticApmAgentStartupHook\StartupHook.cs:line 118
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
   at System.StartupHookProvider.ProcessStartupHooks()

To Reproduce

Steps to reproduce the behavior:

  1. Create a docker container with ENV DOTNET_STARTUP_HOOKS=/app/ElasticApmAgentStartupHook.dll
  2. Run
  3. Profit

Expected behavior

Container should run

Actual behavior

Container failed to run at start up

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions