Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, you can do this with Visual Studio. You have two options:</p> <h3>Configure your project to start the external program</h3> <ol> <li><p>Open your DLL project.</p></li> <li><p>On the properties for the project, go to the <strong>Debug</strong> tab.</p></li> <li><p>Choose <strong>Start external program</strong> and give the path of the external program that will call your DLL, along with any command-line arguments you may need to supply, and the working directory if that's relevant.</p></li> <li><p>Save the project.</p></li> <li><p>Set breakpoints in your code where you want them.</p></li> <li><p>Press F5 to start debugging. <em>(At this point, your breakpoints will say that they won't be hit because the symbols aren't loaded. Don't worry about that for now.)</em></p></li> <li><p>Do whatever you do to make the external application load your library and run your code.</p></li> </ol> <p>Visual Studio will detect the module load, load the symbols, and stop on the breakpoint.</p> <h3>Attach to an existing process</h3> <p>If you can't start the process but instead have to attach to a process that's already running, you can do that too:</p> <p><em>(Side note: If you're using the "Express" edition of Visual Studio, I don't <strong>think</strong> it has this feature, but I'm not certain about that. It's easy enough to tell: You'll either have the menu item mentioned on Step 4 below or not.)</em></p> <ol> <li><p>Make sure the process is running.</p></li> <li><p>Open your DLL project.</p></li> <li><p>Set your breakpoints, etc.</p></li> <li><p>From the <strong>Debug</strong> menu, choose <strong>Attach to process...</strong></p></li> <li><p>In the resulting dialog box, find the process in the list, highlight it, and click <strong>Attach</strong>.</p></li> <li><p>Visual Studio will go into debug mode. <em>(At this point, your breakpoints will say that they won't be hit because the symbols aren't loaded. Don't worry about that for now.)</em></p></li> <li><p>Do whatever you do to make the external process load and run your code.</p></li> </ol> <p>Visual Studio will detect the module load in the external process, load your symbols, and stop on your breakpoint.</p> <hr> <p><strong>N.B.</strong> In both cases, if the external process loads your DLL from somewhere other than the <code>bin/Debug</code> folder of your project, you must make sure you copy the DLL to that other location <em>every time you build it</em> (you can set that up to happen automatically in the project options). Otherwise, Visual Studio won't be able to detect that the DLL being loaded is the one you're trying to debug.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload