AnsweredAssumed Answered

Unspecified error when running the Buffer tool.

Question asked by ccposton on Aug 14, 2012
Latest reply on Aug 14, 2012 by kenbuja
Hello,

I'm getting the following exception thrown when trying to run a Geoprocessing tool:

"Error HRESULT E_FAIL has been returned from a call to a COM component."    at ESRI.ArcGIS.Geoprocessing.GeoProcessorClass.Execute(String Name, IVariantArray ipValues, ITrackCancel pTrackCancel)    at ESRI.ArcGIS.Geoprocessor.Geoprocessor.ExecuteInner(IGPProcess process, ITrackCancel trackCancel, IGeoProcessor igp, IVariantArray iva)    at ESRI.ArcGIS.Geoprocessor.Geoprocessor.Execute(IGPProcess process, ITrackCancel trackCancel)    at GisViewer.GeoprocessingDialog.<RunSelectedTool>b__0() in C:\TASource\Source\MRA\PACS.NET-1.0\GisViewer\Dialogs\GeoprocessingDialog.cs:line 154



The code I'm using is:

  private IFeatureLayer GetSelectedLayers()   {    foreach (String item in featureList.CheckedItems)    {     for (int i = 0; i < synchronizer.MapControl.LayerCount; ++i)     {      var layer = synchronizer.MapControl.get_Layer(i);      if (layer.Name == item)      {       return layer as IFeatureLayer;      }     }    }     return null;   }    private IGPProcess GetSelectedTool()   {    var selectedTool = (GeoprocessorCommand.Command)toolCombo.SelectedItem;     if (selectedTool == GeoprocessorCommand.Command.Buffer)    {     var tool = new ESRI.ArcGIS.AnalysisTools.Buffer();     tool.in_features = GetSelectedLayers();     tool.out_feature_class = outputText.Text;     return tool;    }    else if (selectedTool == GeoprocessorCommand.Command.Clip)    {     var tool = new ESRI.ArcGIS.AnalysisTools.Clip();     return tool;    }    else if (selectedTool == GeoprocessorCommand.Command.Dissolve)    {     //var tool = new ESRI.ArcGIS.AnalysisTools.     //return tool;    }    else if (selectedTool == GeoprocessorCommand.Command.Intersect)    {     var tool = new ESRI.ArcGIS.AnalysisTools.Intersect();     return tool;    }    else if (selectedTool == GeoprocessorCommand.Command.Merge)    {     //var tool = new ESRI.ArcGIS.AnalysisTools     //return tool;    }    else if (selectedTool == GeoprocessorCommand.Command.Union)    {     var tool = new ESRI.ArcGIS.AnalysisTools.Union();     return tool;    }    return null;   }    private void RunSelectedTool()   {    new Thread(new ThreadStart(     delegate()     {      var processor = new Geoprocessor();      var tool = GetSelectedTool();       if (tool != null)      {       try       {        var results = (IGeoProcessorResult)processor.Execute(tool, null);        if (results.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)        {         for (int i = 0; i < results.OutputCount; ++i)         {          var outputVal = results.GetOutput(i);          if (outputVal is DEFeatureClass)          {          }         }        }       }       catch (Exception)       {        MessageBox.Show("There was an error while running the geoprocessor", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);       }      }     }    )).Start();   }


I'm only testing the Buffer tool currently. I've checked, and the tool has both the in_features and out_feature_class assigned correctly before running the process. Any clues?

Thanks,
George Faraj

Outcomes