How to Run Instrumentation Profiling with a DLL in Visual Studio 2019 and 2022

test code 1 Reputation point
2025-08-11T05:41:35.19+00:00

In Visual Studio 2017, the Performance Profiler (Instrumentation mode) lets you select both a DLL and an EXE file. However, in Visual Studio 2019 and 2022, I am unable to select a DLL using the Debug → Performance Profiler → Instrumentation option.

What I’ve Tried:

I modified my Visual Studio 2022 installation to include the Windows Performance Toolkit component. After this, the option to add an item in the Instrumentation menu appeared. I was then able to select the DLL along with the EXE, and the profiler ran and closed properly. The summary window was displayed.

Issue:

Although the profiler completed successfully, the summary showed no data(Hot path call tree, Function view etc). I ensured that the PDB file for the DLL was present in the same directory, as selecting a DLL without its PDB file results in an error.

Question:

How can I correctly run Instrumentation profiling with a DLL in Visual Studio 2019 or 2022 and ensure that performance data is properly captured and displayed similar to Visual Studio 2017?

Developer technologies | Visual Studio | Testing
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Susmitha T (INFOSYS LIMITED) 160 Reputation points Microsoft External Staff
    2025-08-12T08:16:00.1966667+00:00

    Hope you are doing good! Thank you for reaching out. Please find the answer below.

     

    1. Ensure Release Mode: Make sure your project is set to Release configuration before running the instrumentation. Debug mode may not give you the detailed profiling data you expect.  

    2. Use Performance Explorer Instead of Debug → Performance Profiler:

    •  Open Performance Explorer (Alt + F2 or via Analyze → Performance Profiler).  Create a new Instrumentation Profiling Session.
    •  Right-click Targets → Add Target Binary → Select your DLL.
    •  Also add the EXE that loads the DLL (if applicable).
    •  Right-click the session → Start Profiling.  

    3. Instrumentation Tool: Since you've already added the Windows Performance Toolkit, select the Instrumentation checkbox in the Performance Profiler. Then, begin the profiling session by clicking the Start button.

    4. Start with Collection Paused: If you've previously enabled the "Start with collection paused" feature and forgot to hit the Record button, this might explain the lack of data. Make sure you are actively recording during the profiling session.

     

    5. Dynamic Instrumentation: If applicable for your DLL, utilize the new dynamic instrumentation feature introduced in Visual Studio 2022, which can capture data more effectively for certain applications.

    Limitation: Visual Studio’s newer dynamic instrumentation may not support unmanaged C++ DLLs as robustly as older static instrumentation did.

     

    6. Analyzing Output: Once profiling is complete, check the summary for any potential issues. If there’s still no data provided in the Hot path call tree, verify if your code paths are being hit during the execution.

     

    7. Verify Profiler Configuration: Check your Application Insights profiler configuration to ensure it is correctly set up if your application uses it.

    8. Ensure Symbol Resolution: In the profiler summary window, click Symbol Settings.

    • Add the path to the .pdb file manually if it’s not automatically detected.
    • Make sure the DLL was compiled with full debug info (/Zi compiler flag).

     

    9.Verify Source Mapping: If source code isn’t showing, the PDB might lack source paths.

    Rebuild the DLL with source indexing enabled (/Fd and /FS flags).

    If you continue experiencing issues after trying these suggestions, could you provide additional details?

    • Are you using any specific third-party libraries that might conflict with the profiling?
    • Have you tried profiling a simpler application or a sample DLL to see if the issue persists?
    • Could you specify if there were any error messages or warnings during the profiling run?
    • Is there any specific behavior in Visual Studio that indicated a problem mid-way through the profiling session?

    If issue still persist after following all the steps, we’ll be happy to assist further if needed." Kindly mark the answer as accepted if the issue resolved".

     

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.