# Loading profiler failed during CoCreateInstance

**URL:** <https://discuss.elastic.co/t/loading-profiler-failed-during-cocreateinstance/351775>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [January 25, 2024, 6:47am UTC](https://discuss.elastic.co/t/loading-profiler-failed-during-cocreateinstance/351775 "2024-01-25T06:47:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Melyanets\_Pavel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/melyanets_pavel/32/131090_2.png) [@Melyanets\_Pavel](https://discuss.elastic.co/u/Melyanets_Pavel)\
**Post date:** [January 25, 2024, 6:47am UTC](https://discuss.elastic.co/t/loading-profiler-failed-during-cocreateinstance/351775/1 "2024-01-25T06:47:51Z")

</div>

**APM Agent language and version** : apm-agent-dotnet v1.25.3

**Kibana version** : 7.17.13

**Elasticsearch version** : 7.17.13

**APM Server version** : 7.17.13

**Browser version** : is not applicable

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: download page

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

I use APM auto instrumentation for the web application running under IIS 10. It works good when capture requests to MVC controllers. But I have also a bunch of WCF services I want to profile. Since APM agent can not capture WCF method names I use `Elastic.Apm.Agent.Tracer.StartTransaction` method to push data to the APM server.  
Actually data is pushed to the APM server however I always get the following error in the event viewer when the application is started

`.NET Runtime version 4.0.30319.0 - Loading profiler failed during CoCreateInstance. Profiler CLSID: '{FA65FE15-F085-4681-9B20-95E04F6C03CC}'. HRESULT: 0x8007007e. Process ID (decimal): 18408. Message ID: [0x2504].`

I don't have any other profilers installed that may cause the conflict. I added a tracelistener as described [here](https://www.elastic.co/guide/en/apm/agent/dotnet/current/troubleshooting.html) and got the follolwing:

```auto
[2024-01-24 15:28:15.160 +01:00][86][Error] - {BackendCommComponentBase (CentralConfigurationFetcher)} WorkLoop Current thread: `ElasticApmCentralConfigurationFetcher' (managed ID: 86)+-> Exception: System.Threading.ThreadAbortException: Thread was being aborted.
   at System.Threading.Monitor.ObjWait(Boolean exitContext, Int32 millisecondsTimeout, Object obj)
   at System.Threading.ManualResetEventSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.SpinThenBlockingWait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.InternalWait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Elastic.Apm.BackendComm.CentralConfig.CentralConfigurationFetcher.WorkLoopIteration()
   at Elastic.Apm.BackendComm.BackendCommComponentBase.WorkLoop()

[2024-01-24 15:28:15.160 +01:00][80][Error] - {BackendCommComponentBase (PayloadSenderV2)} WorkLoop Current thread: ElasticApmPayloadSenderV2' (managed ID: 80)+-> Exception: System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Monitor.ObjWait(Boolean exitContext, Int32 millisecondsTimeout, Object obj) at System.Threading.ManualResetEventSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.SpinThenBlockingWait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.InternalWait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.Dataflow.DataflowBlock.Receive[TOutput](ISourceBlock1 source, TimeSpan timeout, CancellationToken cancellationToken)
   at Elastic.Apm.Report.PayloadSenderV2.ReceiveBatch()
   at Elastic.Apm.Report.PayloadSenderV2.WorkLoopIteration()
   at Elastic.Apm.BackendComm.BackendCommComponentBase.WorkLoop()

```

What actually tells me nothing.

I have another profiled applications running under the same IIS server and they do not produce any errors. Moreover if I run this code on my local windows 11 machine (also IIS 10) I don't get any errors and see captured SQL statements as well what I don't have on the production machine.

There were conflicts connected with `System.Diagnostics.DiagnosticSource` library coming somewhere from the EntityFramework.Core 3.14 library referenced from one of the packages the application uses what made me add the binding redirect in the web.config

```auto
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />

```

To be onest I'm not sure if this could be the source of the issue so I kindly ask you for assistance to get to the bottom.

---

<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:** [February 22, 2024, 6:48am UTC](https://discuss.elastic.co/t/loading-profiler-failed-during-cocreateinstance/351775/2 "2024-02-22T06:48:02Z")

</div>

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