调试 HTTP 处理程序
我在 2003 年使用 IIS 6。我创建了一个继承自 IHttpAsyncHandler 的 HTTP 处理程序 dll。该 dll 构建到 inetpub\www8080root\common\bin 目录中。它的目的是拦截所有请求。
该网站设置为监视端口8080。我在www8080root目录中创建了一个公共文件夹,并在II6中创建了一个虚拟目录来指向它。 我在公共目录中创建了一个 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#,调试 HTTPHandler
编辑: 通过添加 Debugger.Break(),我现在收到消息“w3wp.exe 已触发断点”,它允许我选择调试环境,但它加载时没有
No symbols are loaded for any call stack frame. The source code cannot be displayed.
我设置的符号“工具”->“选项”->“调试”->“调试”。仅启用我的代码 我将路径设置为从中加载符号的 common/bin 位置。任何手动设置的断点仍然显示:
The breakpoint will not currently be hit. No symbols have been loaded for this document.
编辑: 当它加载时,它似乎正在寻找 ntdll.pdb 的符号。即使我手动加载 httpHandler 的符号文件也没有什么区别。
不过,代码肯定正在执行。
I am using IIS 6 on 2003. I have created a HTTP handler dll that inherits from IHttpAsyncHandler. The dll builds into the inetpub\www8080root\common\bin directory. It is meant to intercept all requests.
The web site is set to monitor port 8080. I have created a common folder in the www8080root directory and have created a virtual directory in II6 to point to it.
I created a web.config file in the common directory
<?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>
When I access http://localhost:8080/common/index.html the HTTP handler causes a crash of w3wp.exe, when I look in the event logs I can see the error within the handler that caused the crash. When I set a breakpoint within VS 2005 the code it doesn't get hit.
In order to debug I need to somehow attach to the process when it is running under IIS but as soon as it processes a request, it crashes.
How do I debug a HTTP Handler dll under IIS? I can't see a aspnet_wp.exe process to attach to as described here: C#, Debugging an HTTPHandler
EDIT:
By adding Debugger.Break() I now receive the message "w3wp.exe has triggered a breakpoint" and it allows me to select a debug environment, but it loads without symbols
No symbols are loaded for any call stack frame. The source code cannot be displayed.
I set Tools->Options->Debugging->Enable Just My Code
I set the path to the common/bin location to load symbols from. Any manually set breakpoints still display:
The breakpoint will not currently be hit. No symbols have been loaded for this document.
EDIT:
When it loads it appears to be looking for the symbols of ntdll.pdb. Even if I manually load the symbol file for the httpHandler it makes no difference.
The code is definitely executing though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在异常发生之前添加几行
Debugger.Break()
。这应该会弹出一个窗口,要求附加调试器。Add
Debugger.Break()
a few lines before the exception occurs. This should give you a popup asking to attach a debugger.问题是 .Net 的安装早于 IIS 版本。我注意到“编辑配置”按钮被禁用,并发现此网站 http://www.warfiblog。 com/edit-configuration-disabled。
按照说明进行操作:
这样做解决了调试问题!
The problem was that .Net had been installed prior to the version IIS. I had noticed the "Edit configuration" button was disabled and found this site http://www.warfiblog.com/edit-configuration-disabled.
Following the instructions:
In doing that it fixed the debugging issue!