Problem when executing Dissolve method in ArcEngine

المشرف العام

Administrator
طاقم الإدارة
I'm always having a problem in GP.execute() when trying to execute this method. Here is my code:

Friend Function DissolveFeatures(ByVal pInFLayer As ESRI.ArcGIS.Carto.IFeatureLayer, ByVal DissolveField As String, ByVal OutName As String) As ESRI.ArcGIS.Carto.IFeatureLayer Dim GP As New ESRI.ArcGIS.Geoprocessor.Geoprocessor Dim Dissolve As ESRI.ArcGIS.DataManagementTools.Dissolve = New ESRI.ArcGIS.DataManagementTools.Dissolve Dim pFLayer As ESRI.ArcGIS.Carto.IFeatureLayer = New ESRI.ArcGIS.Carto.FeatureLayer Try GP.AddOutputsToMap = True GP.OverwriteOutput = True GP.SetEnvironmentValue("workspace", "Database Connections\IFE connexion.sde") Dissolve.in_features = pInFLayer Dissolve.dissolve_field = DissolveField Dissolve.out_feature_class = "Database Connections\IFE connexion.sde\" & OutName RunTool(GP, Dissolve, Nothing) pFLayer.FeatureClass = CType(GP.Open(OutName), IFeatureClass) pFLayer.Name = pFLayer.FeatureClass.AliasName Catch ex As Exception MsgBox(ex.Message & "Dissolve Features") End Try Return pFLayer End Function Private Shared Sub RunTool(ByVal geoprocessor As ESRI.ArcGIS.Geoprocessor.Geoprocessor, ByVal process As IGPProcess, ByVal TC As ITrackCancel) ' Set the overwrite output option to true geoprocessor.OverwriteOutput = True Try geoprocessor.Execute(process, Nothing) ReturnMessages(geoprocessor) Catch err As Exception Console.WriteLine(err.Message) ReturnMessages(geoprocessor) End Try End Sub ' Function for returning the tool messages. Private Shared Sub ReturnMessages(ByVal gp As ESRI.ArcGIS.Geoprocessor.Geoprocessor) ' Print out the messages from tool executions Dim Count As Integer If gp.MessageCount > 0 Then For Count = 0 To gp.MessageCount - 1 Console.WriteLine(gp.GetMessage(Count)) Next End If End Sub This returns an error:

Error HRESULT E_FAIL has been returned from a call to a COM component

Please help.



أكثر...
 
أعلى