Geoprocessing from ArcObjects. Help, what's wrong?

513
2
07-03-2010 08:22 AM
BrianBorg
New Contributor
I have a geoprocessing model that accept 3 parameters [layer as layerfile, clipfeatures as shape file and outputF as string]. This model clips the layer by the clipfeatures shape file and then exports the result. WHen running the model from arcInfo the model works fine but I need to call it from an Arcobjects webservices. The problem is that I am receiving a com exception error. Attached you will find the code, please help me, what is wrong with the code? The model is attached too

public string GeoprocessingLayerClipAndExport()
    {
        try
        {
         
            //Call Geoprocessing model
            ESRI.ArcGIS.Geoprocessor.Geoprocessor GP = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            GP.AddToolbox(@"C:\Users\xxxx\Desktop\LEMIS\Geoprocessing\Export.tbx");

            // Generate the array of parameters.
            IVariantArray parameters = new VarArrayClass();
            parameters.Add(@"C:\temp\test.lyr");   //input layer
            parameters.Add(@"C:\temp\clipexport\ClipF.shp"); //shape file
            parameters.Add("SHAPE, C:\\temp\\exportshape\\"); //export
            GP.OverwriteOutput = true;
            GP.Execute("ClipandExport", parameters, null);
            return "ok";
        }
        catch (Exception ex)
        {
            return "error";
        }
    }
0 Kudos
2 Replies
USFS_AGOLAdministrator
New Contributor III
I noticed a space in the word geoprocessing in your pathname.  Could that be the problem?
0 Kudos
ChangGuo
New Contributor

Hi, Brian, I know it has been a long time since you post this question, But I still want to ask if you've solved this problem. My codes are just like yours and I want to publish it as a service. If you can see this post,  please help me out.

0 Kudos