Debugging C # code from another application

I am loading dll (C #) from QTP. Is it possible to debug C # code when running the qtp test.

+1
source share
2 answers

Yes, you can debug in the dll you can, but you will need a source (if you do not want to look at the disassembly), and you will also need PDBs (debug symbols) to build. It is quite easy to configure ...

  • run the qtp application
  • start a visual studio
  • open the source code and make sure pdb are in the same directory as dll
  • in VS go to debug menu and select attach to process command
  • In the list of processes, select the QTP process and click "Attach"
  • Set breakpoint in code
  • Run the tests that execute the code, and if all is well, you must click the breakpoint

NOTE: if a breakpoint is not pressed, VS probably cannot find the PDB, and you either need to add a path in the options in VS (or something to find them).

Also, try disabling "Enable only my code" on the options page "Tools-> Options-> Debugging" if it still does not work (mainly if you are looking at the released embedded code).

Update: Reply to the comment ... If you go to Tools-> Options ... Select "Debug" in the list on the left and expand it, then select "Symbols", which you can add paths for VS to search for symbols. In addition, if you do not have exact characters, you can right-click the breakpoint and select a location and check the option that allows the characters to not synchronize.

Hope this helps!

+5
source

You can insert a call to Debugger.Break() and start the external application when the breakpoint is reached. Windows will prompt you to debug the exception.

Choosing debugging will allow you to run code after breaking inside Visual Studio and set breakpoints inside your code.

If you are using Vista / Win7, you may need to enable debugging - see this post to find out how.

+2
source

Source: https://habr.com/ru/post/1494215/


All Articles