Apm-agent-dotnet: [BUG] Error - Object reference not set to an instance of an object. at StartupHook.InvokerLoaderMethod(Assembly loaderAssembly) in C:\repos\apm-agent-dotnet\src\ElasticApmAgentStartupHook\StartupHook.cs:line 179

Created on 16 Oct 2021  路  2Comments  路  Source: elastic/apm-agent-dotnet

I have installed the APM agent for the instrumentation of my apps, but when I follow these steps elastic.co/guide/en/apm/agent/dotnet/current/setup-dotnet-net-core.html#zero-code-change-setup I get the error:

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:repos\apm-agent-dotnet\src\ElasticApmAgentStartupHook\StartupHook.cs:line 179

I include this environment for logs, but I don麓t have any message
ELASTIC_APM_STARTUP_HOOKS_LOGGING=1
https://www.elastic.co/guide/en/apm/agent/dotnet/current/troubleshooting.html

APM Agent version

1.10.0.0
I also tried the
1.11.1

Environment

Operating system and version:
Windows Server 2019 Standard

.NET Framework/Core name and version (NET Core 3.1.100) :

Application Target Framework(s) (e.g. netcoreapp3.1):

Describe the bug

When I include the environment DOTNET_STARTUP_HOOKS like this document > https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-dotnet-net-core.html#zero-code-change-setup I get the error below (When I started my app or generated a new deployment):

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:repos\apm-agent-dotnet\src\ElasticApmAgentStartupHook\StartupHook.cs:line 179

To Reproduce

Steps to reproduce the behavior:

  1. Use the config default to APM-SERVER, just include my password and user to Elasticsearch
  2. Then call 'my app using a get to swagger'
  3. See error
    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:repos\apm-agent-dotnet\src\ElasticApmAgentStartupHook\StartupHook.cs:line 179

    Expected behavior

I expected my APM and my app to run normally, without errors, my server is running with the default config

Actual behavior

When I start my agent with the process described here > elastic.co/guide/en/apm/agent/dotnet/current/setup-dotnet-net-core.html#zero-code-change-setup, I get the error:

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:repos\apm-agent-dotnet\src\ElasticApmAgentStartupHook\StartupHook.cs:line 179

bug agent-dotnet

All 2 comments

Hi @Talits, thanks for reporting. I see that the issue has now been closed- did you solve the problem?

Yes, I have solved :), I changed my NuGet packages versions and works perfectly. Thanks!

Was this page helpful?
0 / 5 - 0 ratings