iis调试asp.net_调试以100%运行的ASP.NET工作进程

iis调试asp.net

iis调试asp.net

A co-worker stopped by this week with a strange problem in one of our Web Applications. Sometimes I'm Chief Debugger more than Chief Architect, but I enjoy the forensics.

一位同事因我们的一个Web应用程序中的一个奇怪问题而在本周停下来。 有时候,我比首席架构师更能担任首席调试员,但是我喜欢取证工作。

He found that when developing one of our web sites, the ASP.NET worker process on his machine would hang at around 100%. He'd made a few changes and couldn't check in until he figured out what was up.

他发现在开发我们的一个网站时,其计算机上的ASP.NET辅助进程将挂在100%左右。 他做了一些更改,直到他弄清楚是怎么回事才检查。

I installed Process Explorer and right-clicked on the worker process and went to the Threads Tab (a darned useful tab). It said that ReleaseFusionInterfaces was doing all the work. (I don't know the internals of the CLR to know what it's doing. Fusion is the Assembly Loader and I know what Release does. ;) I suspect that Suzanne Cook might know.) It seemed to me at this point that work WAS being done, but we were in an infinite or very long running loop.

我安装了Process Explorer,并在工作进程上单击鼠标右键,然后转到Threads选项卡(该按钮非常有用)。 它说ReleaseFusionInterfaces正在完成所有工作。 (我不知道CLR的内部知道它在做什么。Fusion是Assembly Loader,我知道Release的作用。;)我怀疑Suzanne Cook可能知道。 )在我看来,目前工作已经完成,但是我们处于无限或长期运行的循环中。

We tried selecting Debug | Break from Visual Studio.NET, but the IDE became confused and dropped into the editor with the instruction pointer (represented by a the selected yellow line) ending up inside of an XML Comment. It was totally confused.

我们尝试选择Debug | 从Visual Studio.NET中断,但是IDE变得混乱,并使用结束于XML Comment内部的指令指针(由选定的黄线表示)落入编辑器。 这是完全混乱的。

When you select the Call Stack from the Debug Windows Menu, code that (basically) you didn't write will be marked as <Non-User Code> and hidden/collapsed within the stack view, as seen in the screenshot to the right.

当从“调试Windows”菜单中选择“调用堆栈”时,(基本上)您未编写的代码将被标记为<非用户代码>,并且在堆栈视图中会隐藏/折叠,如右图的屏幕快照所示。

As with almost all things within Windows, right-click will set you free. Right-click on everything. If you right-click within the Call-Stack Window you can select "show non-user code." and you'll see the full stack. (This is one of many places that the IDE tries to make things easier by "lying" to you. Another is the DebuggerStepThrough Attribute.)

与Windows中几乎所有事物一样,单击鼠标右键可以将您释放。 右键单击所有内容。 如果在Call-Stack窗口中单击鼠标右键,则可以选择“显示非用户代码”。 然后您会看到完整的堆栈。 (这是IDE试图通过“撒谎”使您变得更轻松的许多地方之一。另一个是DebuggerStepThrough属性。)

In the final screenshot with the non-user code visible within the stack, you can see that we're stuck on RegexInterpreter.Go(). It's very possible to create Regular Expressions that will run until the Sun burns out. It may seem like we're stuck in a loop, and perhaps this Regex would have eventually finished at some point, but of course it really needs to take just a few milliseconds.

在最后的屏幕快照中,堆栈中可见非用户代码,您可以看到我们被困在RegexInterpreter.Go()上。 创建将一直运行到太阳烧掉的正则表达式是很有可能的。 似乎我们陷入了一个循环,也许这个Regex最终会在某个时候完成,但是当然,它实际上只需要几毫秒的时间。

We have a layer on top of ResourceManager.GetString() that is called GetStringMacro(). Some resources might have references to other resources, using a custom "macro" format we developered. A resource might be: "For assistance call [PhoneNumber]" where PhoneNumber is another resource that we'll need to resolve with another call to GetString. The regular expression pulls the stuff embedded within []'s out.

我们在ResourceManager.GetString()之上有一个称为GetStringMacro()的层。 使用我们开发的自定义“宏”格式,某些资源可能引用了其他资源。 资源可能是:“用于协助呼叫[PhoneNumber]”,其中PhoneNumber是我们需要通过另一次调用GetString来解决的另一种资源。 正则表达式将嵌入在[]内的内容提​​取出来。

If you look at the last sceenshot at the first/top black line, you'll notice that the string literal being passed into ParseMacroString is missing the final ] bracket. Apparently our regular expression REALLY didn't like the lack of symmetry in this string. We'll need to fix the RegEx to be more robust, but for this problem, as soon as we fixed the string, everything worked and the RegEx executed in milliseconds again.

如果您查看第一行/顶部黑色行的最后一个场景,您会注意到传递给ParseMacroString的字符串文字缺少最后的]括号。 显然,我们的正则表达式确实不喜欢此字符串中缺乏对称性。 我们需要修复RegEx使其更健壮,但是对于这个问题,一旦我们修复了字符串,一切正常,RegEx又在毫秒内执行了。

Now playing: Rent - Goodbye Love

现在播放:租金-再见爱

翻译自: https://www.hanselman.com/blog/debugging-the-aspnet-worker-process-running-at-100

iis调试asp.net

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值