0

I am also get a error shows like "Error HRESULT E_FAIL has been returned from a call to a COM component." And the Exception snapshot shows the "stacktrace" is at "ESRI.ArcGIS.Geoprocessing.GeoProcessorClass.Execute". Can you help me to solve it?

The thing is that I can using the geoprocessor by C#, but can't using it by vb.net. Is it something wrong with the setting or .NET framework? Also, the Com Exception is -2147467259!

Private Sub RunBuffer()

    Dim gp As IGeoProcessor2 = New GeoProcessor()
    gp.OverwriteOutput = True
    Dim sev As Object = Nothing

    Try
        Dim parameters As IVariantArray = New VarArray()
        gp.AddToolbox("C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Data Management Tools.tbx")
        gp.SetEnvironmentValue("workspace", "C:\gp\AirportsAndGolf\golf.gdb")

        parameters.Add("C:\gp\AirportsAndGolf\golf.gdb\Airports")
        parameters.Add("C:\gp\AirportsAndGolf\golf.gdb\Airports_buff2")
        parameters.Add("1000 meters")

        gp.Execute("Buffer_analysis", parameters, Nothing)

       Console.WriteLine(gp.GetMessages(sev))

    Catch ex As Exception
        ' Print generic exception messages.
        Console.WriteLine(ex.Message)
        ' Print geoprocessing execution error messages.
        Console.WriteLine(gp.GetMessages(sev))
    End Try

End Sub

  • That com error is E_FAIL, which is generic and not really helpful in this case. Just to eliminate some easy things, have you tried adding the toolbox that the buffer tool is in (Analysis Tools). You are already adding the Data Management Tools. – Evil Genius Jan 24 '14 at 18:31
1

There are multiple Issues with your code.

Firstly, this is the old way of running Geoprocessing. You should Instead run Geoprocessing using the Managed Assembly. More Details are available in this document

Secondly, You should have correct Error Handling, which is also given in the above link.

  • Thanks for your comment. However, problem can't be solved. Actually, we can run a geoprocessing tool by using the Geoprocessing library methods or by the geoprocessor managed assembly methods. "For information about the basic differences between the two approaches, see Executing tools. In both cases, the Execute method of the geoprocessor is called". resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/… – huaiwei Feb 3 '14 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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