# ELK APM .NET System.NullReferenceException

**URL:** <https://discuss.elastic.co/t/elk-apm-net-system-nullreferenceexception/321765>\
**Category:** APM\
**Tags:** dotnet, language-clients\
**Created:** [December 21, 2022, 12:41pm UTC](https://discuss.elastic.co/t/elk-apm-net-system-nullreferenceexception/321765 "2022-12-21T12:41:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aysekisik\_kisilan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aysekisik_kisilan/32/104385_2.png) [@aysekisik\_kisilan](https://discuss.elastic.co/u/aysekisik_kisilan)\
**Post date:** [December 21, 2022, 12:41pm UTC](https://discuss.elastic.co/t/elk-apm-net-system-nullreferenceexception/321765/1 "2022-12-21T12:41:06Z")

</div>

Kibana version: 8.5.3

Elasticsearch version: 8.5.3

APM Server version: 8.5.3

APM Agent language and version: C# .NET 4.7.3,

Agent Profiler Version: v1.19.0  
Browser version: N/A

Profiler Auto instrumentation: Internet Information Services (IIS) .NET Framework.

Hi, I was testing .NET Apm. I got this error when I checked \elastic\apm-agent-dotnet\logs.

```auto
[ERROR] exception whilst instrumenting integration <Elastic.Apm.Profiler.Managed.Integrations.AdoNet.CommandExecuteNonQueryIntegration, Oracle.ManagedDataAccess.Client.OracleCommand>
System.NullReferenceException: Object reference not set to an instance of an object.
   at Elastic.Apm.Model.Span.TryToCompressRegular(Span sibling)
   at Elastic.Apm.Model.Span.TryToCompress(Span sibling)
   at Elastic.Apm.Model.Span.End()
   at Elastic.Apm.Model.DbSpanCommon.EndSpan(ISpan span, IDbCommand dbCommand, Outcome outcome, Nullable`1 duration)
   at Elastic.Apm.Profiler.Managed.Integrations.AdoNet.DbSpanFactory`1.EndSpan(ApmAgent agent, IDbCommand command, ISpan span, Exception exception)
   at Elastic.Apm.Profiler.Managed.Integrations.AdoNet.CommandExecuteNonQueryIntegration.OnMethodEnd[TTarget,TReturn](TTarget instance, TReturn returnValue, Exception exception, CallTargetState state)
   at CommandExecuteNonQueryIntegration.OnMethodEnd.OracleCommand.Int32(OracleCommand , Int32 , Exception , CallTargetState )
   at Elastic.Apm.Profiler.Managed.CallTarget.Handlers.EndMethodHandler`3.Invoke(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state)
   at Elastic.Apm.Profiler.Managed.CallTarget.CallTargetInvoker.EndMethod[TIntegration,TTarget,TReturn](TTarget instance, TReturn returnValue, Exception exception, CallTargetState state)
   at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteNonQuery()

```

I followed the steps here[.( Profiler Auto instrumentation)](https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-auto-instrumentation.html#_internet_information_services_iis)

There was no problem with the installation. We were seeing services and traces but still wondering about this error. Do I need to worry about this?

---

<div class="post-metadata">

**Author:** ![Wolfgang\_Ziegler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfgang_ziegler/32/109929_2.png) [@Wolfgang\_Ziegler](https://discuss.elastic.co/u/Wolfgang_Ziegler)\
**Post date:** [December 21, 2022, 1:58pm UTC](https://discuss.elastic.co/t/elk-apm-net-system-nullreferenceexception/321765/2 "2022-12-21T13:58:45Z")

</div>

Hi @aysekisik_kisilan,

thanks for reporting this. You might have discovered a small issue here (that should not impact your application, however).

Do you have a Kibana screenshot that you could post here by any chance?  
I would be interested if you are seeing any **database spans** and what their **names** are.

Thanks  
Wolfgang

---

<div class="post-metadata">

**Author:** ![aysekisik\_kisilan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aysekisik_kisilan/32/104385_2.png) [@aysekisik\_kisilan](https://discuss.elastic.co/u/aysekisik_kisilan)\
**Post date:** [December 21, 2022, 2:23pm UTC](https://discuss.elastic.co/t/elk-apm-net-system-nullreferenceexception/321765/3 "2022-12-21T14:23:40Z")

</div>

Hi @Wolfgang_Ziegler ,  
Thank you for your reply. Are these screenshots helpful to you?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/8/88b9fa8fd5099f85b9c4042e383c4b17c41a61f0.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/6/a648472dbde0dfeb3ab832f00e73720ec8a737f9.png)

Thank you

---

<div class="post-metadata">

**Author:** ![Wolfgang\_Ziegler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfgang_ziegler/32/109929_2.png) [@Wolfgang\_Ziegler](https://discuss.elastic.co/u/Wolfgang_Ziegler)\
**Post date:** [December 21, 2022, 8:23pm UTC](https://discuss.elastic.co/t/elk-apm-net-system-nullreferenceexception/321765/4 "2022-12-21T20:23:11Z")

</div>

Yes, that's helpful, thanks!

Would you want to try out a beta version to see if the exception log goes away or do you want to wait for the next release?

(As I said, it's not a serious bug though)

---

<div class="post-metadata">

**Author:** ![aysekisik\_kisilan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aysekisik_kisilan/32/104385_2.png) [@aysekisik\_kisilan](https://discuss.elastic.co/u/aysekisik_kisilan)\
**Post date:** [December 22, 2022, 11:11am UTC](https://discuss.elastic.co/t/elk-apm-net-system-nullreferenceexception/321765/5 "2022-12-22T11:11:17Z")

</div>

@Wolfgang_Ziegler thank you,  
If it's not a serious problem, I can continue to use it as v1.19.0. How can I stop elastic\_apm\_profiler? Is it enough to remove the variables that I have set to iis pools? and Do I need to restart iis after remove?

---

<div class="post-metadata">

**Author:** ![Wolfgang\_Ziegler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfgang_ziegler/32/109929_2.png) [@Wolfgang\_Ziegler](https://discuss.elastic.co/u/Wolfgang_Ziegler)\
**Post date:** [December 22, 2022, 11:53am UTC](https://discuss.elastic.co/t/elk-apm-net-system-nullreferenceexception/321765/6 "2022-12-22T11:53:15Z")

</div>

Yes, removing the environment variables and restarting the IIS app pools stops the profiler.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 12, 2023, 7:53am UTC](https://discuss.elastic.co/t/elk-apm-net-system-nullreferenceexception/321765/7 "2023-01-12T07:53:22Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
