geogeek14

Execute Arctool from ArcObjects

Discussion created by geogeek14 on Jul 10, 2012
Latest reply on Jul 15, 2012 by nahmed-esristaff
i cannot execute Arcgis Toolbox tools using the code below, VS 2010 indicates that the error comes from the gp.execute() function, i've tried this code with the "Buffer" tool but it seems the i can't run any tool using this code.

Any help please

i use ArcObjects 10.1 , VS 2010 , Framework .NET 4.0

Thanks in advance


   IVariantArray parameters = new VarArrayClass();
            IGeoProcessor2 gp = new GeoProcessorClass();
            try
             {

            gp.AddToolbox(@"C:\Program Files\ArcGIS\ArcPad10.0\DesktopTools10\ArcPad Tools.tbx");
            //gp.AddToolbox(@"c:\program files\arcgis\desktop10.1\ArcToolbox\Toolboxes\Analysis Tools.tbx"); 
            gp.SetEnvironmentValue("Workspace", @"C:\Documents and Settings\Administrateur\Mes documents\ArcGIS\Default.gdb");
            parameters.Add(@"C:\Documents and Settings\Administrateur\Bureau\geo_db\test.axf");
            //parameters.Add(@"C:\Documents and Settings\Administrateur\Mes documents\ArcGIS\Default.gdb\gone");
            //parameters.Add(@"C:\Documents and Settings\Administrateur\Mes documents\ArcGIS\Default.gdb\gone_bif");
            parameters.Add("");
            parameters.Add("");
            gp.Execute("ArcPadCheckin", parameters, null); /// the problem in this line

                }
               catch (Exception ex)
               {
                   var sev = 2;
                   label1.Text = label1.Text + gp.GetMessages(sev);
                   label1.Text = label1.Text + ex.StackTrace;
               }

Outcomes