从UnsafeNativeMethods.DispatchMessageA引发的异常 [英] Exception thrown from UnsafeNativeMethods.DispatchMessageA
问题描述
我使用了第三部分组件,该组件为非托管C ++组件提供了托管包装器.
I've used a third part component which provided a managed wrapper to unmanaged C++ component.
但是UnsafeNativeMethods.DispatchMessageA有时会引发异常.然后我的应用程序崩溃了.无论如何要捕捉那些异常以避免我的应用崩溃?
But UnsafeNativeMethods.DispatchMessageA throws exception from time to time. Then my app crashes. Anyway to catch those exceptions to avoid my app crashing?
未处理的异常: System.Exception:错误: 可以 不能 获取 已注册 类型-
mteIndex ='4294967295'classNameKey =''
在Kitware.mummy.Runtime.Methods中. GetConstructorInfo (UInt32 mteIndex)
在Kitware.mummy.Runtime.Methods.CreateWrappedObjectImpl(UInt32 mteStatus,UInt32 mteIndex,UInt32 rawRefCount,IntPtr rawCppThis,布尔值callDisposalMethod,
布尔值和创建)
在Kitware.mummy.Runtime.Methods.CreateWrappedObject(UInt32 mteStatus,UInt32 mteIndex,UInt32 rawRefCount,IntPtr rawCppThis,布尔值callDisposalMethod,
布尔值和找到)
在Kitware.VTK.vtkObjectEventRelay.Execute(IntPtr调用方,UInt32 eventId,IntPtr callData)上
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageA(MSG& msg)
在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID,
Int32原因,Int32 pvLoopData)
在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32原因,ApplicationContext上下文)中
在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32原因,ApplicationContext上下文)中
在System.Windows.Forms.Application.RunDialog(窗体窗体)中
at System.Windows.Forms.Form.ShowDialog(IWin32Window所有者) 在System.Windows.Forms.Form.ShowDialog()
Unhandled Exception: System.Exception: error: could not get registered type -
mteIndex='4294967295' classNameKey=''
at Kitware.mummy.Runtime.Methods.GetConstructorInfo(UInt32 mteIndex)
at Kitware.mummy.Runtime.Methods.CreateWrappedObjectImpl(UInt32 mteStatus, UInt32 mteIndex, UInt32 rawRefCount, IntPtr rawCppThis, Boolean callDisposalMethod,
Boolean& created)
at Kitware.mummy.Runtime.Methods.CreateWrappedObject(UInt32 mteStatus, UInt32 mteIndex, UInt32 rawRefCount, IntPtr rawCppThis, Boolean callDisposalMethod,
Boolean& found)
at Kitware.VTK.vtkObjectEventRelay.Execute(IntPtr caller, UInt32 eventId, IntPtr callData)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageA(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID,
Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
问候,
zlf
推荐答案
糟糕! 该异常似乎是在初始化过程的早期发生的.特别是,表单刚刚被加载,并启动了一个消息循环.邮件已发送.最终:Kitware.mummy.Runtime.Methods.CreateWrappedObject 开始它的魔力并死亡.因为其中包含运行时"一词,所以它意味着动态加载正在进行中,当我们看到诸如"GetContructorInfo"之类的方法时,情况似乎就是如此.
Ouch! This exception appears to be happening very early in the initialization process. In particular the form just gets loaded, and starts up a message loop. The message is dispatched. Ulitimately: Kitware.mummy.Runtime.Methods.CreateWrappedObject starts it's magic and dies. Because it contains the words Runtime, it implies there is dynamic loading going on which seems to be the case when we see a method such as "GetContructorInfo"..
我认为这段代码不是防弹的,该错误是CreateWrappedObject的责任,并且我看不到如何通过此错误获取....除非存在dll方面的问题,否则发生中.. 换句话说,以后需要DLL 在动态绑定中未加载或未找到.这可能是时间问题,但不确定.
It is my opinion that this code is not bullet-proof, the error is the responsibility of CreateWrappedObject and I do not see how you could get by this error....unless there is something dll-wise that isn't happening.. In other words a DLL needed later in the dynamic binding either isn't loaded or isn't found. It could be a timing issue but am not sure.
这篇关于从UnsafeNativeMethods.DispatchMessageA引发的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!