从其他应用程序调试 C# 代码

发布于 2024-08-07 10:53:36 字数 48 浏览 2 评论 0原文

我正在从 QTP 加载 dll (c#)。 qtp测试开始时是否可以调试c#代码。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

書生途 2024-08-14 10:53:36

是的,您可以调试 dll,但是您将需要源代码(除非您想查看反汇编),并且您还需要程序集的 PDB(调试符号)。设置非常简单...

  1. 启动QTP应用程序
  2. 启动Visual Studio
  3. 打开源代码并确保pdb与
  4. VS中的dll位于同一目录中转到调试菜单并选择附加到进程
  5. 在进程列表中,选择QTP进程并单击“附加”
  6. 在代码中设置断点
  7. 启动执行代码的测试,如果一切正常,您应该命中断点

注意:如果未命中断点,VS可能找不到 PDB,您需要在 VS 的选项中添加路径(或其他内容以便它可以找到它们)。

另外,如果“工具”->“选项”->“调试”选项页面中的“仅启用我的代码”仍然无法正常工作,请尝试关闭它(主要是如果您正在查看发布构建的代码)。

更新:回答评论...如果您转到“工具”->“选项”...选择左侧列表中的“调试”并展开它,然后选择“符号”,您可以在其中添加路径让 VS 搜索符号。另外,如果您没有确切的符号,您可以右键单击断点并选择位置,然后选中允许符号不同步的选项。

希望这有帮助!

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!

赢得她心 2024-08-14 10:53:36

您可以插入对 Debugger.Break() 的调用并运行外部应用程序,当到达断点时,Windows 将提供您调试异常的功能。

选择调试将使您能够在 Visual Studio 中中断后运行代码,并在代码中设置断点。

如果您使用的是 Vista/Win7,您可能需要启用调试 - 请查看 这篇文章 了解如何操作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文