日期:2014-05-20  浏览次数:20753 次

有个Exception居然 Catch 不住,特高分请教高手
问题是这样的,我在程序中要调用一个Activex控件,当该控件的运行环境被破坏掉时,在release析构该控件的对象时会抛出一个异常,我就加了try...catch语句,在按F5   调试代码的时候,可以看到这个异常被catch住了,但是如果直接运行可执行文件的时候,这个异常就不能被catch住,好像时被.net   framework   catch住的,然后提示
See   the   end   of   this   message   for   details   on   invoking  
just-in-time   (JIT)   debugging   instead   of   this   dialog   box.

**************   Exception   Text   **************
System.AccessViolationException:   Attempted   to   read   or   write   protected   memory.   This   is   often   an   indication   that   other   memory   is   corrupt.
      at   System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr   wndProc,   IntPtr   hWnd,   Int32   msg,   IntPtr   wParam,   IntPtr   lParam)
      at   System.Windows.Forms.NativeWindow.DefWndProc(Message&   m)
      at   System.Windows.Forms.Control.DefWndProc(Message&   m)
      at   System.Windows.Forms.Control.WndProc(Message&   m)
      at   System.Windows.Forms.AxHost.WndProc(Message&   m)
      at   System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&   m)
      at   System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&   m)
      at   System.Windows.Forms.NativeWindow.Callback(IntPtr   hWnd,   Int32   msg,   IntPtr   wparam,   IntPtr   lparam)


**************   Loaded   Assemblies   **************
mscorlib
        Assembly   Version:   2.0.0.0
        Win32   Version:   2.0.50727.42   (RTM.050727-4200)
        CodeBase:   file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Autoloader
        Assembly   Version:   1.0.0.0
        Win32   Version:   1.0.0.0
        CodeBase:   file:///H:/lib/Debug/Autoloader.exe
----------------------------------------
Connectivity.Common
        Assembly   Version:   1.0.2564.32478
        Win32   Version:   1.0.2564.32478
        CodeBase:   file:///H:/lib/Debug/Connectivity.Common.DLL
----------------------------------------
System
        Assembly   Version:   2.0.0.0
        Win32   Version:   2.0.50727.42   (RTM.050727-4200)
        CodeBase:   file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
.
.
.
.
.
.
.
.
.
.
.
.

**************   JIT   Debugging   **************
To   enable   just-in-time   (JIT)   debugging,   the   .config   file   for   this
application   or   computer   (machine.config)   must   have   the
jitDebugging   value   set   in   the   system.windows.forms   section.
The   application   must   also   be   compiled   with   debugging
enabled.

For   example: