0

I published and successfully accessed a GP service in ArcMap 10.2, but I couldn't make it work in my .NET program using ArcObjects 10.2:

        IGeoProcessor gp = new GeoProcessorClass();
        gp.AddToolbox(@"http://localhost:6080/arcgis/rest/services;mygpfolder/testsel");

        //input
        IGPUtilities2 gputils = new GPUtilitiesClass();
        IFeatureClass fc = (IFeatureClass)gputils.OpenDatasetFromLocation(@"E:\input.shp");
        IRecordSetInit recordset = new RecordSetClass();
        recordset.SetSourceTable((ITable)fc, null);
        IGPRecordSet gprecordset = new GPFeatureRecordSetLayerClass();
        gprecordset.RecordSet = (IRecordSet)recordset;

        IGPFeatureRecordSetLayer recordlayer = new GPFeatureRecordSetLayerClass();
        recordlayer = gprecordset as IGPFeatureRecordSetLayer;

        IVariantArray parameters = new VarArrayClass();
        parameters.Add(recordlayer);

        gp.Execute("Select", parameters, null);           

I got "Error HRESULT E_FAIL has been returned from a call to a COM component." at "gp.Execute". The GP service is published using tool "Select" under toolbox "Analysis" in ArcMap:

enter image description here

Any suggestions?

1 Answer 1

1

The tool is called Select_analysis, there are a few things called 'select' and you have to specify the one you want. The vague error doesn't help but it can't find a geoprocessing tool called 'select'.

gp.Execute("Select_analysis", parameters, null);

it may be worth noting that a geoprocessor tool returns a value of type IGeoProcessorResult which you can get your messages using GetResultMessages. This will at least give you some inkling why the tool failed.

4
  • Hi Michael,it shows the same error with "Select_analysis",and I updated the post with a screen shot of the service.I just assumed that I should use the name under Tasks
    – l.z.lz
    Commented May 29, 2014 at 1:47
  • Is your ArcGis server licensed for geoprocessing? Commented May 29, 2014 at 1:51
  • I'm not familiar with ArcGIS server so I'm not sure what do you mean by licensed? but I coulde execute the GP service via web browser and arcmap
    – l.z.lz
    Commented May 29, 2014 at 2:18
  • Then it must be. The basic level of license for ArcGis server does not include geoprocessing esri.com/library/brochures/pdfs/… (page 2) have a look at the result object and see if you get some messages there, that might help. Commented May 29, 2014 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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