# profiler auto-instrumention not working in IIS10

**URL:** <https://discuss.elastic.co/t/profiler-auto-instrumention-not-working-in-iis10/370740>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [November 19, 2024, 6:54am UTC](https://discuss.elastic.co/t/profiler-auto-instrumention-not-working-in-iis10/370740 "2024-11-19T06:54:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ysj2018](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ysj2018/32/139318_2.png) [@ysj2018](https://discuss.elastic.co/u/ysj2018)\
**Post date:** [November 19, 2024, 6:54am UTC](https://discuss.elastic.co/t/profiler-auto-instrumention-not-working-in-iis10/370740/1 "2024-11-19T06:54:37Z")

</div>

I would like to use Elastic APM's profiler auto-instrumentation to monitor our .NET application. I first tested it on Windows 10, but the profiling was unsuccessful. I followed the steps described on the official website:

1. I downloaded the Elastic APM Profiler version 1.30.0 and extracted it to a directory on Windows 10.
2. I created a basic application using .NET 5.0.408 (which provides a page with a button that, when clicked, uses HttpClient to access Baidu) (the test was functional).
3. I packaged it into a specific directory.
4. I enabled IIS features on Windows 10:

- .NET Extensibility 4.6
- ASP
- [ASP.NET](http://ASP.NET) 4.6

1. I created an application pool (selected "No Managed Code" for the .NET CLR version and "Integrated" for the managed pipeline mode).
2. I created a website (assigned port 8081).
3. I published the application to the specified path of the website, and the application was functional.
4. I modified the `web.config` file to add environment variables with the following configuration:

```auto
xml<?xml version="1.0" encoding="utf-8"?><configuration> <location path="." inheritInChildApplications="false"> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\WebApplication3.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess"> <environmentVariables> <environmentVariable name="ELASTIC_APM_SERVICE_NAME" value="dotnettest" /> <environmentVariable name="COR_ENABLE_PROFILING" value="1" /> <environmentVariable name="COR_PROFILER_PATH" value="D:\agent\elastic_apm_profiler.dll" /> <environmentVariable name="ELASTIC_APM_PROFILER_HOME" value="D:\agent\" /> <environmentVariable name="ELASTIC_APM_PROFILER_INTEGRATIONS" value="D:\agent\integrations.yml" /> <environmentVariable name="ELASTIC_APM_SERVER_URL" value="http://localhost:8200" /> <environmentVariable name="ELASTIC_OTEL_LOG_LEVEL" value="trace" /> <environmentVariable name="ELASTIC_OTEL_LOG_DIRECTORY" value="D:\agent\logs" /> <environmentVariable name="ELASTIC_APM_APPLICATION_PACKAGES" value="D:\IIS\" /> <environmentVariable name="ELASTIC_APM_PROFILER_LOG_DIR" value="D:\agent\log" /> <environmentVariable name="COR_PROFILER" value="{FA65FE15-F085-4681-9B20-95E04F6C03CC}" /> </environmentVariables> </aspNetCore> </system.webServer> </location></configuration>

```

1. I restarted the application, and the application was accessible normally, but I did not see any trace data (I had APM Server 7.10 running and configured to output data to Kafka), nor did I see any profiler loading logs.
2. I restored the `web.config` and directly configured the variables as system variables, then restarted the application, but still did not see the profiler being loaded.

What could be the possible reasons? Are there any issues with my operations?

---

<div class="post-metadata">

**Author:** ![stevejgordon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevejgordon/32/80912_2.png) [@stevejgordon](https://discuss.elastic.co/u/stevejgordon)\
**Post date:** [November 19, 2024, 10:34am UTC](https://discuss.elastic.co/t/profiler-auto-instrumention-not-working-in-iis10/370740/2 "2024-11-19T10:34:07Z")

</div>

As per my response in the [GitHub issue](https://github.com/elastic/apm-agent-dotnet/issues/2485):

[@ysj2018](https://github.com/ysj2018), Have you [viewed the profiler](https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-auto-instrumentation.html#_internet_information_services_iis) documentation? We provide a script to configure the environment variables against the app pool. Using `web.config` is untested for [ASP.NET](http://ASP.NET) Core.

You have used the incorrect environment variables for your app. For [ASP.NET](http://ASP.NET) Core (.NET 5+) you should be using:

```auto
CORECLR_ENABLE_PROFILING = "1"
CORECLR_PROFILER = "{FA65FE15-F085-4681-9B20-95E04F6C03CC}"
CORECLR_PROFILER_PATH = "$profilerHomeDir\elastic_apm_profiler.dll"

```

`COR_PROFILER` etc. is for .NET Framework.

Please try using the documented scripting approach to enable profiling, and let us know if you have any issues after that.
