【问题标题】:debugging a HTTP Handler调试 HTTP 处理程序
【发布时间】:2012-01-03 06:45:14
【问题描述】:

我在 2003 年使用 IIS 6。我创建了一个继承自 IHttpAsyncHandler 的 HTTP 处理程序 dll。 dll 构建到 inetpub\www8080root\common\bin 目录中。它旨在拦截所有请求。

网站设置为监控8080端口。我在www8080root目录下创建了一个common文件夹,并在II6中创建了一个虚拟目录指向它。 我在 common 目录下创建了一个 web.config 文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
    <compilation debug="true" defaultLanguage="c#" />
    <httpHandlers>
        <add verb="*" path="*"
            type="x2Handler.x2Handler, x2Handler" />
    </httpHandlers>
</system.web>
</configuration>

当我访问http://localhost:8080/common/index.html 时,HTTP 处理程序导致 w3wp.exe 崩溃,当我查看事件日志时,我可以在处理程序中看到导致崩溃的错误。当我在 VS 2005 中设置断点时,代码不会被命中。

为了调试,当它在 IIS 下运行时,我需要以某种方式附加到该进程,但一旦它处理请求,它就会崩溃。

如何在 IIS 下调试 HTTP Handler dll?我看不到要附加到的 aspnet_wp.exe 进程,如下所述:C#, Debugging an HTTPHandler

编辑: 通过添加 Debugger.Break() 我现在收到消息“w3wp.exe 已触发断点”,它允许我选择调试环境,但它加载时没有符号

No symbols are loaded for any call stack frame. The source code cannot be displayed.

我设置了 Tools->Options->Debugging->Enable Just My Code 我将路径设置为 common/bin 位置以从中加载符号。仍会显示任何手动设置的断点:

The breakpoint will not currently be hit. No symbols have been loaded for this document.

编辑: 当它加载时,它似乎正在寻找 ntdll.pdb 的符号。即使我手动加载 httpHandler 的符号文件也没有什么区别。
代码肯定在执行。

【问题讨论】:

  • 它所指的符号是一个符号数据库,它是您在Visual Studio的“调试”配置中构建应用程序时创建的。文件扩展名为 .pdb,请确保它对调试器可用。

标签: c# debugging iis httphandler


【解决方案1】:

在异常发生前几行添加Debugger.Break()。这应该会给您一个弹出窗口,要求您附加调试器。

【讨论】:

  • 感谢您的帮助。它按照你说的做了,但我仍然无法调试。
【解决方案2】:

问题是 .Net 已在 IIS 版本之前安装。我注意到“编辑配置”按钮被禁用并找到此站点http://www.warfiblog.com/edit-configuration-disabled。 按照说明操作:

You will need to go to Start -> Microsoft Visual Studio 2005 -> Visual Studio Tools -> Visual Studio 2005 Command Prompt. On the prompt write down this command:
aspnet_regiis -r
The above command will register dot net with IIS and now the button will also be enabled.

这样做解决了调试问题!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-04
    相关资源
    最近更新 更多