none
Error when accessing a COM component RRS feed

  • Question

  • I am attempting to make an allpication that manipulates MS Access using the standard PIAs.

    In doing so, I recieve a COM error whenever I attempt to handle an event exposed by the PIA for an object that exists in the Access database (such as a form or controll).

    This error ocurs only when I attempt to handle an event for an object that is already part of the Access database. If I create an object in my managed code and then add it to the database (such as a toolbar) then I can handle the events as normal.

    Specificaly, as soon as I try to add a handler I get a System.Runtime.InteropServices.COMException with an HRESULT of 0x80040202.

    Here is a StackTrace:

        at System.Runtime.InteropServices.UCOMIConnectionPoint.Advise(Object pUnkSink, Int32& pdwCookie)
        at Microsoft.Office.Interop.Access._FormEvents_EventProvider.add_Close(_FormEvents_CloseEventHandler )
        at Microsoft.Office.Interop.Access._FormEvents_Event.add_Close(_FormEvents_CloseEventHandler )
        at AccessWrapperTestApp.Form1.set_myForm(Form WithEventsValue)
        at AccessWrapperTestApp.Form1.Form1_Load(Object sender, EventArgs e) in D:\Visual Studio 2008\Projects\AccessWrapperTestApp\AccessWrapperTestApp\Form1.vb:line 41
        at System.EventHandler.Invoke(Object sender, EventArgs e)
        at System.Windows.Forms.Form.OnLoad(EventArgs e)
        at System.Windows.Forms.Form.OnCreateControl()
        at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
        at System.Windows.Forms.Control.CreateControl()
        at System.Windows.Forms.Control.WmShowWindow(Message& m)
        at System.Windows.Forms.Control.WndProc(Message& m)
        at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
        at System.Windows.Forms.ContainerControl.WndProc(Message& m)
        at System.Windows.Forms.Form.WmShowWindow(Message& m)
        at System.Windows.Forms.Form.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
        at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
        at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
        at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
        at System.Windows.Forms.Control.set_Visible(Boolean value)
        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.Run(ApplicationContext context)
        at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
        at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
        at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
        at AccessWrapperTestApp.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
        at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
        at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
        at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
        at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
        at System.Threading.ThreadHelper.ThreadStart()

    I searched for anything related to UCOMIConnectionPoint.Advise() and found this page with some information:
        http://msdn.microsoft.com/en-us/library/cc218766.aspx

    However, that doesn't seem to lead me to a solution.

    Do you have any ideas that may help or have you ever seen this error before?

    Tuesday, July 22, 2008 8:59 PM

Answers

  • The generic diagnostic for 0x80040202 is that the object doesn't recognize the event callback interface.  As to why this happens with Access is quite beyond the scope of this forum.  Access doesn't use the CLR.  You'll need to find an Office programming support forum or newsgroup.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Tuesday, July 29, 2008 10:29 AM
    • Marked as answer by Zhi-Xin Ye Tuesday, July 29, 2008 10:30 AM
    Wednesday, July 23, 2008 6:19 PM
    Moderator