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)
Else
pParams.RemoveAll()
pParams.Add("F:\SD_Tools\HEL_Tool\Hel_1.gdb\sumHEL2_template")
pParams.Add(tempDir)
pParams.Add(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?