'System.Runtime.InteropServices.InvalidComObjectException'

micropathic

Well-known member
Joined
Oct 23, 2003
Messages
75
Any ideas as to why this snippet of code is throwing the error:


An unhandled exception of type System.Runtime.InteropServices.InvalidComObjectException occurred in mscorlib.dll

Additional information: COM object that has been separated from its underlying RCW can not be used


Code:

Code:
 ****************Code uses "Srego" activeX control to pull and push files to and from specified device***********************************************

        MsgBox actualspvpath
        overallprogressbar.Visible = True
        Picture1.Visible = True

        Label2.Text = " "
        Label3.Text = " "

          List1.Clear
        System.Windows.Forms.Application.DoEvents()

        If SregoCETPx1.PullFileEx(SPVDirResult, PCDirResult, "/d") Then App.Path & "\RubbersSSyncIT", "/d") Then
            System.Windows.Forms.Application.DoEvents()

            List1.Items.Add("File Sync From Device Completed Successfully.")
            Label2.Text = "File Sync From Device Completed Successfully."
        Else
            System.Windows.Forms.Application.DoEvents()

            List1.Items.Add("No files To Copy From The Device")
            Label2.Text = "No Files To Copy From The Device"
        End If

        List1.Items.Add("")






        System.Windows.Forms.Application.DoEvents()


        If SregoCETPx1.PushFileEx(PCDirResult & "\" & "*.*", SPVDirResult, "/d") Then
            System.Windows.Forms.Application.DoEvents()

            List1.Items.Add("File Sync To Device Completed Successfully.")
            Label3.Text = "File Sync To Device Completed Successfully."
        Else
            MsgBox "source" & (mydir)
            MsgBox "destination" & myspvdir
            System.Windows.Forms.Application.DoEvents()

            List1.Items.Add("No Files To Copy To The Device")
            Label3.Text = "No Files To Copy To The Device"
        End If


        List1.Items.Add("")

        Dim gg1, b As Short
        If chkLogSync.CheckState = 1 Then

            gg1 = FreeFile()
            FileOpen(gg1, VB6.GetPath & "\" & "sync.log", OpenMode.Append)
            For b = 0 To List1.Items.Count - 1
                WriteLine(gg1, VB6.GetItemString(List1, b))
            Next
            FileClose(gg1)
        Else
            do nothing
        End If

        Form1.DefInstance.overallprogressbar.Value = 0

         overallprogressbar.Visible = False
        Picture1.Visible = False

        ************************************************


        Form1.DefInstance.overallprogressbar.Value = 0

ANY help would be greatly appreciated!!!
 
Maybe this is an easier question:

How can I make my application catch this error and just exit instead of making the error visible?
 
Back
Top