# Dotnet profiler auto instrument not working

**URL:** <https://discuss.elastic.co/t/dotnet-profiler-auto-instrument-not-working/371893>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [December 12, 2024, 6:18am UTC](https://discuss.elastic.co/t/dotnet-profiler-auto-instrument-not-working/371893 "2024-12-12T06:18:26Z")\
**Posts on this page:** 1\
**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:** [December 12, 2024, 6:18am UTC](https://discuss.elastic.co/t/dotnet-profiler-auto-instrument-not-working/371893/1 "2024-12-12T06:18:26Z")

</div>

I would like to use dotnet Profiler Auto instrumentation to probe my test application developed based on the .NET Framework, but it's not working.

Details about my application:

- The test application is developed using .NET Framework 4.8.1.
- It runs normally and functions correctly.

Details about my computer:

- My computer's operating system is Windows 11.
- The pre-installed .NET Framework version on my computer is 4.8.

Details about my development environment:

- I use Rider 2024 as my development tool.
- When creating the project, the target framework selected was 4.8.1.
- When building the project, v4.0 was chosen.
- For publishing, I chose a local folder.

I packaged and published the project on IIS and configured environment variables with the script as follows:

```auto
$appcmd = "$($env:systemroot)\system32\inetsrv\AppCmd.exe"
$appPool = "test" 
$profilerHomeDir = "D:\IIS\agent\agent" 
$environment = @{
  COR_ENABLE_PROFILING = "1"
  COR_PROFILER = "{FA65FE15-F085-4681-9B20-95E04F6C03CC}"
  COR_PROFILER_PATH = "$profilerHomeDir\elastic_apm_profiler.dll"
  ELASTIC_APM_PROFILER_HOME = "$profilerHomeDir"
  ELASTIC_APM_PROFILER_INTEGRATIONS = "$profilerHomeDir\integrations.yml"
  COMPlus_LoaderOptimization = "1" 
  ELASTIC_APM_SERVER_URL = "http://localhost:8200" 
  ELASTIC_APM_SERVICE_NAME = "dotnetlocalframework_-_PVVMDC0228"
  ELASTIC_APM_METRICS_INTERVAL = 0
  ELASTIC_APM_CAPTURE_BODY = "errors"
  ELASTIC_APM_SPAN_STACK_TRACE_MIN_DURATION = "-1"
}
$environment.Keys | ForEach-Object {
  & $appcmd set config -section:system.applicationHost/applicationPools /+"[name='$appPool'].environmentVariables.[name='$_',value='$($environment[$_])']"
}

```

The project runs normally, but the profiler did not successfully attach.

An error was found in the Event Viewer: "NET Runtime version 4.0.30319.0 - Failed to load profiler during CoCreateInstance. Profiler CLSID: '{FA65FE15-F085-4681-9B20-95E04F6C03CC}'. HRESULT: 0x800700c1. Process ID (decimal): 26524. Message ID: [0x2504]."

What could be the possible reasons for this?
