# Elastic APM Agent asp.net startup hooks dll

**URL:** <https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [October 13, 2021, 6:46pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655 "2021-10-13T18:46:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryphilli](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@ryphilli](https://discuss.elastic.co/u/ryphilli)\
**Post date:** [October 13, 2021, 6:46pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655/1 "2021-10-13T18:46:28Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

TIP 1: select at least one tag that further categorizes your topic. For example `server` for APM Server related questions, `java` for questions regarding the Elastic APM Java agent, or `ui` for questions about the APM App within Kibana.

TIP 2: Check out the [troubleshooting guide](https://www.elastic.co/guide/en/apm/get-started/current/troubleshooting.html) first. Not only will it help you to resolve common problems faster but it also explains in more detail which information we need before we can properly help you.

**Kibana version** : 7.12.1

**Elasticsearch version** : 7.12.1

**APM Server version** : 7.15

**APM Agent language and version** : 1.11.1 .Net

**Browser version** :

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: releases page [elastic.co](http://elastic.co)

**Fresh install or upgraded from other version?** Fresh

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.  
The application is managed with IIS setting the DOTNET\_STARTUP\_HOOKS variable will not start the agent.  
**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
IIS will not keep or use the environment variable/s when set. I do not know if I am setting the variables correctly or I am not exposing correctly. I am new to setting up Elastic APM Agents and their components.

 ![Screenshot 2021-10-13 134326](https://us1.discourse-cdn.com/elastic/original/3X/d/d/dd879482370a123342cc61927db7faa218a3eec4.png)

**Steps to reproduce** :

1. Having a deployed application on an IIS server 2012
2. set DOTNET\_STARTUP\_HOOKS pointing to \ElasticApmAgentStartupHook.dll
3. Restart the IIS application

**Errors in browser console (if relevant)**: Not relevant

**Provide logs and/or server output (if relevant)**:  
Unable to setup logging for apm agent.

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [October 13, 2021, 7:35pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655/2 "2021-10-13T19:35:39Z")

</div>

Hi @ryphilli,

The 1. environment variable seems ok, but the 2. and the 3. don't. They should be `ELASTIC_APM_SERVER_URLS` and `ELASTIC_APM_VERIFY_SERVER_CERT`. [Here](https://www.elastic.co/guide/en/apm/agent/dotnet/current/config-all-options-summary.html) is the list of the configs - if you click on those, you'll see the environment variable for each.

So I guess the agent ignored the server url which you configured - question is if it works once you fix the environment variable. If it doesn't [here](https://github.com/elastic/apm-agent-dotnet/tree/master/src/ElasticApmAgentStartupHook#troubleshooting) you find more info on how to troubleshoot the startup hook logic.

---

<div class="post-metadata">

**Author:** ![ryphilli](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@ryphilli](https://discuss.elastic.co/u/ryphilli)\
**Post date:** [October 13, 2021, 7:55pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655/3 "2021-10-13T19:55:21Z")

</div>

@GregKalapos thank you for the reply.  
I am wondering where I should be putting these startup hooks environment variables should I be putting them at the topmost position like the server or should it be in the application that I want to monitor that is something that the documentation does not cover. As of now I went to the website level and nothing seems to be happening I even set the elastic\_apm\_startup\_hooks\_logging to 1 and the logfile is not being created. So I am not 100% sure I am placing the environment variables in the correct places.

I think I have them in the right place and still I am getting no logging even though I have the variable set or any indication that it started up.

 ![Screenshot 2021-10-13 161154](https://us1.discourse-cdn.com/elastic/original/3X/7/0/705ffa8a7877eb3cab65b535f73886f0396eafe0.png)

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [October 18, 2021, 1:51am UTC](https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655/4 "2021-10-18T01:51:54Z")

</div>

@ryphilli what .NET version are you targeting e.g. netcoreapp3.1 ?

---

<div class="post-metadata">

**Author:** ![ryphilli](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@ryphilli](https://discuss.elastic.co/u/ryphilli)\
**Post date:** [October 18, 2021, 12:39pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655/5 "2021-10-18T12:39:24Z")

</div>

@forloop I am targeting 4.0 according to IIS, but the application I am targeting does not have a version number associated with it. I am assuming that it is also 4.0 to go along with the other applications deployed.

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [October 18, 2021, 7:25pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655/6 "2021-10-18T19:25:24Z")

</div>

@ryphilli This startup hook feature is only supported on .NET Core 3.0 and newer versions (.NET 5+).

On .NET Full framework (including version 4) this is not supported. Just for completeness: .NET FullFramework (with version 4.x) predates .NET Core 3 - super confusing versioning 🙂

---

<div class="post-metadata">

**Author:** ![ryphilli](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@ryphilli](https://discuss.elastic.co/u/ryphilli)\
**Post date:** [October 18, 2021, 7:37pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655/7 "2021-10-18T19:37:40Z")

</div>

@GregKalapos ,

Thank you for that I was struggling to get it working and now I know that the zero code change route will not work for this implementation. So I will have to go the code change option unless that option also will not work with our environment. But reading through the documentation it should work if I can do the standard setup, but please correct me if I am wrong. I do not want to attempt to change the code if the agent will not work with our version that we are using. Once again thank you for clarifying why it was not working.

Ryan

---

<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:** [November 8, 2021, 3:37pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-asp-net-startup-hooks-dll/286655/8 "2021-11-08T15:37:44Z")

</div>

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