【发布时间】:2014-10-15 14:14:21
【问题描述】:
我有一些调用 Rotativa 的代码,它调用 wkhtml2pdf。我怀疑我看到 wkhtml2pdf.exe 导致抛出损坏状态异常 (CSE) 的行为。如果抛出 CSE,我想捕获并记录它,这样我就可以追踪它发生的位置。
当我让应用程序在调试器中运行过夜时,当我回来时 VS 已关闭。有时它已重新启动,有时则没有。怀疑内存损坏我开始研究并偶然发现了 CSE 处理。
我正在做这样的事情:
[HandleProcessCorruptedStateExceptions]
void DoStuff()
{
try
{
DOThatThingThatMakesTheDebuggerHaltAndShutDown();
}
catch(Exception ex)
{
//how do I detect that it's a CSE in here, so I can log it especially blatantly
}
}
有没有办法检测异常是否是 General Catch 中的 CSE?
我看到他们有 2 个一般例外条款。内部不处理 CSE 并设置一个标志。如果在没有标志的情况下调用外部的,则它是 CSE,但我希望有更清洁的东西。我想做的是记录这个不良状态,然后将其传递给应用程序以正常冒泡。
当我查看导致 VS2013 崩溃的事件日志中的错误时,我得到以下信息:
应用程序:devenv.exe 框架版本:v4.0.30319 描述: 由于未处理的异常,进程被终止。异常信息: 异常代码 c0000005,异常地址 4DA44C1F 堆栈:在 Microsoft.VisualStudio.Debugger.Clr.NativeDkmClrModuleInstance.ProcF4BC786AEBAC294EE9C4C0BB1B0F56A7(IntPtr, IntPtr ByRef) 在 Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance.GetMetaDataImport() 在 Microsoft.IntelliTrace.Concord.MetadataHelper..ctor(Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance) 在 Microsoft.IntelliTrace.Concord.Integration.CpdeNotifyPointServiceAdapter.InstallBreakpoint(Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance, Microsoft.VisualStudio.Debugger.Interop.Internal.NP_INSTALL_REQUEST)
在 Microsoft.IntelliTrace.Concord.Integration.CpdeNotifyPointServiceAdapter.BindToModule(Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance) 在 Microsoft.IntelliTrace.Concord.IntelliTraceProcessState.AlertModuleLoad(Microsoft.VisualStudio.Debugger.DkmModuleInstance) 在 Microsoft.IntelliTrace.Concord.NotifyPoints.NotifyPointManager.OnModuleInstanceLoad(Microsoft.VisualStudio.Debugger.DkmModuleInstance, Microsoft.VisualStudio.Debugger.DkmWorkList, Microsoft.VisualStudio.Debugger.DkmEventDescriptorS) 在 Microsoft.VisualStudio.Debugger.EntryPoint.IDkmModuleInstanceLoadNotification_OnModuleInstanceLoad(IntPtr, IntPtr, IntPtr, IntPtr)
接下来是:
错误应用程序名称:devenv.exe,版本:12.0.30501.0,时间 戳:0x5361f453 错误模块名称:vsdebugeng.impl.DLL,版本: 12.0.30501.0,时间戳:0x5361f482 异常代码:0xc0000005 故障偏移量:0x00094c1f 故障进程 ID:0x1c9c 故障应用程序 开始时间:0x01cfe7cc0cf50465 错误应用程序路径:C:\Program 文件 (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe 错误模块路径:C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\vsdebugeng.impl.DLL 报告 ID:097b17c6-5438-11e4-8409-001f2904053c
【问题讨论】:
-
异常的类型是什么?
-
这是一个 CSE,我只是添加了 CSE 处理代码,因为类型和调用堆栈是我所追求的......由于 CSE 没有被处理,我得到的只是一个停止。 .. 我将从事件查看器中获得的内容添加到问题中
-
你知道
Exception的type吗?如果是这样,您可以使用catch(CorruptedStateException ex)来隔离该特定异常。 -
没有像 CorruptedStateException 这样的东西,CSE 根本不是从 Exception 派生的,它是完全不同的东西。您使用泛型 (Exception ex) 捕获它并将注释添加到要捕获它的方法中,然后仅针对该方法将其重定向到 Exception。这是 .Net 4 中的一个变化 ...这是一篇关于它的好帖子 csbubblog.wordpress.com/2011/12/20/c4-cse
标签: c# exception visual-studio-2013 corrupted-state-exception