我们正在尝试实例化一个 OCX 组件,但它会生成一个未被 try/catch 捕获的异常。
从资源管理器启动应用程序时,会出现一个窗口要求选择调试或关闭应用程序。当我选择 Debug 时,Visual Studio 2012 启动并且我收到以下消息:
Unhandled exception at 0x779ae753 in TestFwComponent.exe: 0xC0000374: A heap has been corrupted.
First-chance exception at 0x770ac41f in TestFwComponent.exe: Microsoft C++ exception: COleDispatchException at memory location 0x0022e228.
First-chance exception at 0x770ac41f in TestFwComponent.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x770ac41f in TestFwComponent.exe: Microsoft C++ exception: EECOMException at memory location 0x0022e5b0.
First-chance exception at 0x770ac41f in TestFwComponent.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x770ac41f in TestFwComponent.exe: 0xE0434352: 0xe0434352.
First-chance exception at 0x770ac41f in TestFwComponent.exe: 0xE0434352: 0xe0434352.
奇怪的是,当我直接用 VS2012 的调试器启动应用程序时,我可以得到异常并继续执行。是的,它很脏,但是这个组件很垃圾,我们必须在使用它之前生成一个异常..
System.Runtime.InteropServices.SEHException was caught
HResult=-2147467259
Message=External component has thrown an exception.
Source=mscorlib
ErrorCode=-2147467259
StackTrace:
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at FwWFLib.FwWFClass.Initialize(String ServerMachineName, String MbxName, String MbxServerProcessName, Object Controls)
at MDT.MicroBackFill.FWClient.Core.Service.FwService.Initialize() in c:\TEMP\TestFwComponent\FwService.cs:line 49
InnerException:
我想知道如何在没有调试器的情况下尝试/捕获生成的异常?