I tend to use ML classification of Spatial Analyst ToolBox in ArcGIS Engine, I wrote this sample code:

        IAoInitialize aoInit = new AoInitialize();
        esriLicenseStatus licStat = aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
        licStat = aoInit.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);

        Geoprocessor gp = new Geoprocessor();

        gp.AddToolbox(@"C:\Program Files (x86)\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\Spatial Analyst Tools.tbx");


        IVariantArray parameters = new VarArrayClass();


        IGeoProcessorResult result;
        result = (IGeoProcessorResult)gp.Execute("MLClassify ", parameters, null);

but unfortunately the code stop with this error:

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

I do not know how to handle it?

The value of LicStat is licStat esriLicenseCheckedOut

The Line result = (IGeoProcessorResult)gp.Execute("MLClassify ", parameters, null); is throwing the non-helpful error

As you said ---ArcGis 10 way is different and as that tool is a python script I'm not sure you can use it that way.--- what is its solution?, what should i do now?

closed as unclear what you're asking by PolyGeo Feb 1 '18 at 7:17

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What is the value of licStat? The code will continue whether the license is checked out or not, see the eunum help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… for possible values. Which line is throwing the non-helpful error? You may need to step through in debug until it breaks and note which line has the error then use try..catch and see if the exception has any more helpful information. – Michael Stimson Aug 24 '14 at 23:21
  • The code you are referring to shows the ArcGis 9.3 or previous way of doing things in Spatial Analyst, the ArcGis 10 way is different and as that tool is a python script I'm not sure you can use it that way. – Michael Stimson Aug 24 '14 at 23:42