C# error “Attempted to read or write protected memory” or “External component has thrown an exception”

前端 未结 2 379
伪装坚强ぢ
伪装坚强ぢ 2021-01-18 03:41

I have a C# program (target framework .NET 4.0) which makes calls to COM objects (unmanaged code), all objects managed properly, destroyed when no longer required, etc.

2条回答
  •  攒了一身酷
    2021-01-18 04:13

    One of your COM coomponents is causing the exception as indicated by:

    Message=External component has thrown an exception

    These two lines should help you locate which COM component and the called method that is causing the problem:

       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    

    I take it that you've written a wrapper in order to interface to these COM components? Or are you using direct Invoke calls?

    Perhaps the InnerException information would give you more details.

    Basically look for anything that you may recognise as being related to these COM components.

提交回复
热议问题