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

03-29-2013 12:26 PM
New Contributor
I am writing a small code to calculate the minimum distance between a point and a curve using the near tool in ArcGIS . The code  is as follows

Imports ESRI.ArcGIS.Geoprocessor
Imports ESRI.ArcGIS.AnalysisTools

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim gp As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor
        Dim neartool As ESRI.ArcGIS.AnalysisTools.Near = New ESRI.ArcGIS.AnalysisTools.Near()
        neartool.in_features = "F:\Rajdeep-Assam\EQ_Source\FaultLine.shp"
        neartool.near_features = "F:\Rajdeep-Assam\EQ_Source\Epicentre_2011.1.1_20.48.shp"
        gp.OverwriteOutput = True
        gp.Execute(neartool, Nothing)
    End Sub
End Class

When i run the code , it shows an error at the line gp.Execute(neartool, Nothing)

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

What are the possible reasons ?
0 Kudos
1 Reply
New Contributor III
Is that because you didn't set up the workspace? I am having the same issue while trying to use a customized tool in my c# code. I think the error means that the code is trying to access some object that is out of bound or can't be found. However it is too generic and doesn't help with debugging. I tried to find the usage and validate messages from the gp tool but with no avail. Anyone got a solution or suggestion on how to trouble shoot? Thanks!
0 Kudos