lrsmith

Application error: ITableWindow2.Show

Discussion created by lrsmith on Dec 5, 2011
Latest reply on Dec 10, 2011 by Hornbydd
I am testing an ArcMap Extension that was written in .Net for ArcGIS 9.3.1 in ArcGIS 10.  One of the custom commands opens the Attribute table for selected features.  The command determines which layer the user wants to open attributes for and then calls the subroutine below to open the layers attribute table. When the ITableWindow2.Show(true) command is issued, ArcGIS 10 errors with "Atttempted to read or write protected memory".     Any help would be greatly appreciated.

Public Sub OpenSelectTable(ByVal layer As ILayer, ByVal SELSET As Boolean, ByVal papp As IApplication)
        Try


            Dim pMxDoc As IMxDocument
            Dim pLayer As ILayer
            Dim pStandaloneTable As IStandaloneTable
            Dim pTableWindow2 As ITableWindow2
            Dim pExistingTableWindow As IDataWindow2

            '  'Get the selected item from the current contents view
            pMxDoc = TryCast(papp.Document, IMxDocument)
            pTableWindow2 = New TableWindow
            ' Determine the selected item's type
            ' Exit sub if item is not a feature layer or standalone table
            'Continue = False
            If TypeOf layer Is IFeatureLayer And layer.Valid Then 'A FeatureLayer
                pLayer = layer
                pExistingTableWindow = TryCast(pTableWindow2.FindViaLayer(pLayer), IDataWindow2)
                ' Check if a table already exists; if not create one
                pTableWindow2.Layer = pLayer
            ElseIf TypeOf layer Is IStandaloneTable And layer.Valid Then
                ' A standalone table
                pStandaloneTable = TryCast(layer, IStandaloneTable)
                pExistingTableWindow = TryCast(pTableWindow2.FindViaStandaloneTable(pStandaloneTable), IDataWindow2)
                ' Check if a table already exists; if not, create one
                pTableWindow2.StandaloneTable = pStandaloneTable
            End If

            pTableWindow2.TableSelectionAction = esriTableSelectionActions.esriDrawFeatures

            pTableWindow2.ShowSelected = SELSET
            pTableWindow2.ShowAliasNamesInColumnHeadings = True
            pTableWindow2.Application = papp
            pTableWindow2.Show(True)

        Catch ex As Exception
            MsgBox("Error support/openselecttable: " & ex.Message)
        End Try
    End Sub

Outcomes