Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a problem when i execute GeoProcessing in ArcEngine 10 with VB.net

  1. i had create the toolbox : Models.tbx
  2. and Model Process : disolveRoute with 2 parameters

enter image description here

My Function is :

 Sub diso()
    Dim dissolveTable As ITable = CType(featureLayerRoute, ITable)
    ' Create geoprocessor. Overwrite true will replace existing output.
    Dim gp As IGeoProcessor2 = New ESRI.ArcGIS.Geoprocessing.GeoProcessor()
    Dim trac As ITrackCancel = New CancelTracker
    Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
    Dim parameters As IVariantArray = New VarArrayClass()
    gp.SetEnvironmentValue("workspace", "Database Connections\IFE connexion.sde")
    gp.OverwriteOutput = True
    gp.AddToolbox("data\Models.tbx")
    parameters.Add(dissolveTable)
    parameters.Add("typeroute")
    Try
        Result = CType(gp.Execute("disolveRoute", parameters, trac), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2)
    Catch ex As COMException
        Console.WriteLine(ex.ErrorCode)
    End Try

End Sub

For the inpute feature for disolve --> featureLayerRoute :

  Dim Sp As IWorkspace = ConnectToTransactionalVersion("localhost", "sde:postgresql:localhost", "sde", "....", "....")
        featureLayerRoute.FeatureClass = featureWorkspace.OpenFeatureClass("piste_route")
        Dim layerrouteAs ILayer = featureLayerDroit
        layerroute.Name = featureLayerRoute.FeatureClass.AliasName

but when i execute this function it returned a Code ERROR -2147467259.. Please it's one Week i'm looking to solve it but Nothing :'(

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

share|improve this question
    
You won't get the detailed error unless you listen to the GP Messages. Additionally, in .NET you should always use the Geoprocessor Class, and not the IGeoProcessor interface. See : help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/… –  Devdatta Tengshe Apr 15 '13 at 11:42
    
Have a look at the code in this sample: help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/… –  Devdatta Tengshe Apr 15 '13 at 11:44
    
Thank you DevDatta, i will tray it and reply you –  AbdelMounaim TAOUSSI Apr 15 '13 at 12:35
    
I Got this ERROR : Failed to execute. Parameters are not valid. ERROR 000840: The value is not a Feature Class. Failed to execute (disolveRoute). –  AbdelMounaim TAOUSSI Apr 15 '13 at 13:54
    
@Mounaim TAOUSSI Is the parameter's order valid? –  Darksanta Apr 21 '13 at 13:30
show 1 more comment

2 Answers

up vote 2 down vote accepted

the solution is :

  1. the new Model is like :

Model disolveRoute

  1. it Paramters like :

parameters for the Model

  1. the Code :

  Sub diso()

        Dim gp As GeoProcessor = New ESRI.ArcGIS.Geoprocessing.GeoProcessor()
        Dim trac As ITrackCancel = New CancelTracker
        Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
        Dim parameters As IVariantArray = New VarArrayClass()

        gp.OverwriteOutput = True
        gp.AddToolbox("data\Models.tbx")
        Dim featureWorkspace As IFeatureWorkspace = CType(Sp, IFeatureWorkspace)
        Dim featureClass As IFeatureClass = featureWorkspace.OpenFeatureClass("piste_route")
        'Dim dissolveTable As IDataset = CType(featureClass, IDataset)
        parameters.Add(featureClass)
        parameters.Add("typeroute")
        parameters.Add("C:\Users\Mounaim\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\IFE connexion.sde\sde.sde.unionPExec")
        Try
            Result = CType(gp.Execute("disolveRoute", parameters, trac), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2)
        Catch ex As Exception
            ExamplePrintGPErrorMessages(gp)
        End Try

    End Sub





 Public Sub ExamplePrintGPErrorMessages(ByVal gp As GeoProcessor)

        Dim sev As Object = 2
        Dim messages As String = gp.GetMessages(sev)
        System.Console.WriteLine(messages)

    End Sub
share|improve this answer
add comment

Are the reference as" Imports System Imports System.Threading ' Add references to esriSystem for licensing and IVariantArray. Imports ESRI.ArcGIS.esriSystem ' Add a reference to the geoprocessing namespace. Imports ESRI.ArcGIS.Geoprocessing 'Imports ESRI.ArcGIS.Geoprocessor "

share|improve this answer
add comment

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.