Debugging into C# code from other application

前端 未结 2 766
Happy的楠姐
Happy的楠姐 2021-01-23 17:26

I\'m loading a dll (c#) from QTP. Is it possible to debug the c# code when the qtp test starts.

相关标签:
2条回答
  • 2021-01-23 18:03

    Yes you can debug into the dll's you can, but you will need source (unless you want to look at the disassembly) and you will also need the PDBs (debug symbols) for the assembly. It is pretty easy to setup...

    1. start the QTP application
    2. start visual studio
    3. open the source code and make sure the pdb's are in the same directory as the dll
    4. in VS go to the debug menu and select attach to process
    5. In the process list, select the QTP process and click "attach"
    6. Set a breakpoint in the code
    7. Start the tests that execute the code and if all is well you should hit the breakpoint

    NOTE: if the breakpoint is not hit, VS probably can't find the PDB's and you either need to add a path in options in VS (or something so it can find them).

    Also, try turning off "Enable just my code" in the Tools->Options->Debugging options page if it is still not working (mostly if you are looking at release built code).

    Update: Answering comment... If you go to Tools->Options... Select "Debugging" on the list on the left and expand that, then select "Symbols" you can add paths there for VS to search for symbols. Also, if you don't have the exact symbols you can right-click the breakpoint and select location and check the option that will allow the symbols to be out of sync.

    Hope this helps!

    0 讨论(0)
  • 2021-01-23 18:26

    You can insert a call to Debugger.Break()and run the external application, when the break point will be reached Windows will offer you to debug the exception.

    Choosing debug will enable you to run the code after the break inside Visual Studio and set break points inside your code.

    In case you're using Vista/Win7 you might need to enable debugging - have a look at this post to learn how.

    0 讨论(0)
提交回复
热议问题