How To Profile A Native DLL Called From A C# Application
Profiling a DLL called from a .NET application is fairly straightforward. In this example, I will demonstrate how to profile a DLL called from a simple C# winform.
Instrument your native code with Error Detection
**If you would like to know how to build and instrument from the command line, view the knowledgebase article located here: http://community.microfocus.com/borland/develop/devpartner_-_code_analysis/w/knowledge_base/21152.msbuild-vs-nmvcbuild.aspx
From the menu of Visual Studio, select "Devpartner>C++ Instrumentation Manager".
- Proceed to build your DLL project in Visual Studio.
- Navigate to the standalone version of Error Detection: Start>Programs>Micro Focus> DevPartner>Error Detection.
Click File>Open and navigate to the executable that will invoke your DLL.
Navigate to Modules and Files.
To start, click on the Play button or navigate to Program>StartProgram>Start.
At this point, if you have instrumented your native code, Error Detection will begin the process of profiling your application for errors, memory leaks, etc.
For example, the application that I created is nothing more than a simple C++ DLL of which a memory leak, and a buffer overrun was added.
During the execution of my simple example, Error Detection reported the following:
Memory Leak Generated in DLL Code
Write Over Run Generated from DLL Code
*Note: If you are not seeing any profiled data. Locate your native DLL in the "Modules Tab" of the session file to verify instrumentation.