Corrupt Memory Error Message

08-20-2012 08:48 AM
Regular Contributor
I've been using the following code for weeks as part of a larger project (ArcGIS 9.2, Visual Studio 2005). It checks to see if a .dbf file exists in C:\temp. If it doesn't, it copies a template table from an FGDB. Once the .dbf is there, it opens an update cursor on it.
            Const tempDir = "C:\temp"
            Dim pGP As IGeoProcessor = New GeoProcessor
            Dim pParams As IVariantArray = New VarArrayClass
            pGP.OverwriteOutput = True
            '...unrelated code deleted...
            Const strOutDBF = "SumHEL2.dbf"
            Dim gpUtils As IGPUtilities = New GPUtilities
            Dim pGPResult As IGeoProcessorResult
            Dim pTable As ITable
            Dim pCursor As ICursor
            Dim pRow As IRow
            If File.Exists(tempDir + "\" + strOutDBF) Then
                pTable = gpUtils.OpenTableFromString(tempDir + "\" + strOutDBF)
                pGPResult = pGP.Execute("TableToTable_conversion", pParams, Nothing)
                pTable = gpUtils.OpenTableFromString(pGPResult.ReturnValue.ToString)
            End If
            pCursor = pTable.Update(Nothing, True)
            pRow = pCursor.NextRow

Today I've started getting this message whenever the code is executed:
A first chance exception of type 'System.AccessViolationException' occurred in SDtools.dll
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at ESRI.ArcGIS.Geoprocessing.GeoProcessorClass.Execute(String Name, IVariantArray ipValues, ITrackCancel pTrackCancel)
   at SDtools.HELanalyze.CreateSumHEL2(IMap pMap, String strFIPS, IFeature pFeat) in C:\Documents and Settings\bruce.nielsen\My Documents\Visual Studio 2005\Projects\SDtools\SDtools\HELanalyze.vb:line 628

The error occurs at either the gpUtils.OpenTableFromString or pGP.Execute line, depending on if the .dbf file exists. Restarting Visual Studio or rebooting the computer had no effect.

Any ideas on why I'm getting this message?
0 Kudos
3 Replies
Occasional Contributor III
Have you tried removing .dbf extension from strOutDBF before adding it to pParams or OpenTableFromString method? The tablename should not have .dbf extension.
0 Kudos
Regular Contributor
That wasn't it.

Also: If I run the TableToTable tool manually, it succeeds in copying the template table to C:\temp.
0 Kudos
Occasional Contributor III
The logic that you have provided inputs "SumHel2.dbf" (Const strOutDBF = "SumHEL2.dbf") and not "SumHel2" as a parameter to the outputTable field. Add "SumHel2.dbf" to Output Table field of TableToTable tool in arccatalog and you will notice "invalid name" error.
0 Kudos