# Running multiple profilers via the Microsoft CLR Instrumentation Engine

## Prerequisites for a multi-profiler setup <a href="#prerequisites-for-a-multi-profiler-setup" id="prerequisites-for-a-multi-profiler-setup"></a>

* 3rd party profiler is configured and supports Microsoft CLR Instrumentation technology. This can be verified by confirming the existence of the **MicrosoftInstrumentationEngine\_x64.dll** in your system.
* SeaLights environment variables are configured for the process or service from which coverage should be collected (see box at end of this page for a list)
* Identify the 3rd party provider's Profiler ID and DLL location

## Configuring the CLR Instrumentation Engine to support 2 profilers running simultaneously <a href="#configuring-the-clr-instrumentation-engine-to-support-2-profilers-running-simultaneously" id="configuring-the-clr-instrumentation-engine-to-support-2-profilers-running-simultaneously"></a>

Once we've confirmed our 3rd party profiler supports running with the CLR Instrumentation Engine, we will need to make some modifications:

1. Ensure the following environment variables are aligned:

   <pre data-overflow="wrap"><code>COR_PROFILER={324F817A-7420-4E6D-B3C1-143FBED6D855}
   COR_PROFILER_PATH_64=C:\&#x3C;path to where the file is>\MicrosoftInstrumentationEngine_x64.dll
   </code></pre>
2. Prepare an XML file to link the two profilers to be referenced in the next step. Please note the following:
   * The first entry refers to the 3rd party profiler, which should run alongside SeaLights.
   * The second entry refers to the SeaLights .NET profiler.
     * The SeaLights Profiler DLL can be x64 or x86 architecture, depending on the architecture of the process from which coverage should be collected
   * **Important: The path to each profiler DLL is relative to the location of this XML config file!**
     * Placing all referenced binaries in the same folder as the XML configuration file will ensure they can be found. *Sample XML is shared below*
3. Define 2 additional environment variables:

   <pre class="language-powershell" data-overflow="wrap"><code class="lang-powershell">MicrosoftInstrumentationEngine_ConfigPath64_=C:\&#x3C;Path to MSCLR XML Configuration file.xml>
   MicrosoftInstrumentationEngine_DisableCodeSignatureValidation=1
   </code></pre>
4. When the service is restarted, it will be running SeaLights along with the 3rd party profiler, which will both run under the Microsoft CLR Instrumentation Engine.

{% code title="MSCLR XML Configuration" overflow="wrap" lineNumbers="true" fullWidth="false" %}

```xml
 <InstrumentationEngineConfiguration>
    <InstrumentationMethod>
        <Name>VS Profiler</Name>
        <Description>Visual Studio Profiler</Description>
        <Module>VSPerfCorProf.dll</Module>
        <ClassGuid>{33708259-ba1b-4add-9de4-d4f280ea1223}</ClassGuid>
        <Priority>60</Priority>
    </InstrumentationMethod>
   
    <InstrumentationMethod>
        <Name>SL Profiler</Name>
        <Description>Sealights .NET profiler</Description>
        <Module>SL.DotNet.ProfilerLib_x64.dll</Module> OR <Module>SL.DotNet.ProfilerLib_x86.dll</Module>
        <ClassGuid>{01CA2C22-DC03-4FF5-8350-59E32A3536BA}</ClassGuid>
        <Priority>50</Priority>
    </InstrumentationMethod>
</InstrumentationEngineConfiguration>
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/.net-core-agent/multiprofiling-running-sealights-side-by-side-with-other-profilers/running-multiple-profilers-via-the-microsoft-clr-instrumentation-engine.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
