Try setting the object to null. In C#:object = null;
Dim pWS2 As IWorkspaceFactory2 = New InMemoryWorkspaceFactory Dim pWS As IWorkspace = pWS2.OpenFromString("GPInMemoryWorkspace", 0) pWS = Nothing
Friend Function CreateNewTable(ByVal TableLocation As String, ByVal TableName As String) As ESRI.ArcGIS.Geodatabase.ITable Dim NewTable As New ESRI.ArcGIS.DataManagementTools.CreateTable Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2 Try Using releaser As New ESRI.ArcGIS.ADF.ComReleaser releaser.ManageLifetime(NewTable) NewTable.out_path = TableLocation NewTable.out_name = TableName Result = RunTool(NewTable, Nothing) If Result Is Nothing Then Return Nothing Return ReturnObjectfromResult(Result, "Table") End Using Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString & vbNewLine & ex.StackTrace.ToString, "Create Table") Return Nothing End Try End Function Friend Function RunTool(ByVal Process As ESRI.ArcGIS.Geoprocessor.IGPProcess, ByVal TC As ESRI.ArcGIS.esriSystem.ITrackCancel2, Optional ByVal AddOutput As Boolean = False) As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2 Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2 Try System.Windows.Forms.Cursor.Current = Windows.Forms.Cursors.WaitCursor Dim GP As New ESRI.ArcGIS.Geoprocessor.Geoprocessor GP.AddOutputsToMap = AddOutput Result = CType(GP.Execute(Process, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2) If Result.Status <> ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded Then ReturnMessages(Result, "Geoprocessing Error") GP.ClearMessages() Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString, "Run Geoprocessor") End Try Return Result End Function Friend Function ReturnObjectfromResult(ByVal result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2, ByVal Type As String) As Object Dim GPVal As ESRI.ArcGIS.Geodatabase.IGPValue Dim InMemFC As String Dim GPUtil As ESRI.ArcGIS.Geoprocessing.IGPUtilities3 = New ESRI.ArcGIS.Geoprocessing.GPUtilities Try GPVal = result.GetOutput(0) InMemFC = GPVal.GetAsText() Select Case Type Case "Feature Class" Return GPUtil.OpenFeatureClassFromString(InMemFC) Case "Table" Return GPUtil.OpenTableFromString(InMemFC) Case "Feature Layer" Return GPUtil.OpenFeatureLayerFromString(InMemFC) Case Else Return Nothing End Select Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString, "ReturnObjectfromResult error") Return Nothing End Try End Function
Dim pGP As IGeoProcessor = New GeoProcessor Dim pParams As IVariantArray = New VarArrayClass pGP.OverwriteOutput = True Dim strMemSpace As String = "in_memory\" Dim strTmpFields As String = "HELfields" pParams.Add(pSelLayer) 'This is the selected polygon layer from the TOC that has been run through some validation code. pParams.Add(strMemSpace + strTmpFields) pGP.Execute("CopyFeatures_management", pParams, Nothing) Debug.Print("Copied the land units")
Public Sub DeleteTable() ' Create Utils object Dim pGPUtils As IGPUtilities Set pGPUtils = New GPUtilities ' Create GPValue object and set path Dim pGPValue As IGPValue Set pGPValue = New DETable pGPValue.SetAsText ("in_memory\abc") ' Delete table pGPUtils.Delete pGPValue pGPUtils.ReleaseInternals End Sub
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.