Geoprocessor Execute HRESULT COM Error

3302
6
11-06-2013 07:47 AM
DavidPlume1
New Contributor III
Hi Everyone,

Recently, I started having problems with my C# projects running geoprocessing tools.  My tools point to custom scripts in project toolboxes.  The code in question has run without issue in the past.

However, something in my environment has changed and even the simplest code throws errors. Please see sample below.

The code fails on gp.Execute();  I've triple checked, labels, names, paths, parameters etc.

I've tried every thing I can think of to track down this problem including re-installing Arc. 

I'm dead in the water if I can't solve this nasty problem.

Thanks in Advance
David

        

private void runTool()
        {
            try
            {
                
                Geoprocessor gp = new Geoprocessor();
                gp.AddToolbox(@"C:\0_Test\Test.tbx");

                IVariantArray parameters = new VarArrayClass();
                parameters.Add(@"MyStringArg");

                // Execute the tool.
                gp.Execute("test", parameters, null);

            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "TestGP Error", System.Windows.Forms.MessageBoxButtons.OK);
                return;
            }
        }
0 Kudos
6 Replies
RichardWatson
Frequent Contributor
No promises but it might help to what the exception is.

My guess is that it is a COMException.  If it is then I'd like to know what the HRESULT is, i.e. ErrorCode.
0 Kudos
DavidPlume1
New Contributor III
Richard,

Thanks for the speedy reply.  The decimal code ErrorCode from the exception is -2147467259.

I've not decoded this but did find a thread that suggest this code is a generic failure code but I'd be grateful for any thread that leads out of this ditch I've veered into!

David
0 Kudos
RichardWatson
Frequent Contributor
Unfortunately, that is E_FAIL which is pretty worthless.  Sorry.

What is the execution context of your code?  Does it run in ArcMap or is it a standalone program?
0 Kudos
DavidPlume1
New Contributor III
Yes, I was afraid of that.  Thanks for checking.

A little background -- I have an add-in extension running in ArcMap 10.1  (.NET Framework 4.0).  This project has been underway for a year or so.  Along the way we developed a number of processes that run geoprocessing tools in a project toolbox.  The project has been on the shelve for a month or so but was running fine last time I did work with it. 

Naturally, I had scheduled a demo to show folks the project on Monday this week.  When I got into it I discovered that none of my gp Executes work.  The toolbox is still valid and the tools execute normally from Catalog.

Eventually I built the simple code block you see above in a separate add-in button to make sure that there wasn't something in the extension that was clobbering things.

When that didn't work I ran a repair on Visual Studio and re-installed Arc.  That did nothing.

I've removed all of my extensions and add-ins except the test case and can not find the problem. 

The toolbox tool (sample code above in original post) is a very simple arcpy script that looks grabs the string parameter and gives it back:

import arcpy

if __name__ == '__main__':
 
 s = arcpy.GetParameter(0)
 arcpy.AddMessage(s)


Thanks Again.
0 Kudos
DuncanHornby
MVP Notable Contributor
Is there a specific reason why you are compiling under the .Net Framework 4?

If I was developing simple tools I would do it under the 3.5 Framework. Have a look at this page if you want to develop in .Net Framework 4.
0 Kudos
PeterBlasko
New Contributor
Hi everyone!

I got the same error. I wrote a program in c# for ArcGIS 9.3.1 and i want to use geoprocessor object for execute a custom toolbox. I added all parameter and use the correct model name (not the label), but when i run it, its give back an ComException with that error code: -2147467259. I translated it and get 80004005 error code. A simple test toolbox i can run with one parameter but this not... i checked the file names model name etc... I hope somebody can help me! Best Regards!

Geoprocessor GP = new Geoprocessor();
IVariantArray parameters = new VarArrayClass();

GP.AddToolbox(@"c:\*\*\VRP_Toolbox_93.tbx");
// the model need 5 parameter but the street.nd map wont be changing so it fix in the model and these i set model parameters
parameters.Add(@"c:\*\*\route.shp");
parameters.Add(@"c:\*\*\depot\depot_miskolc.shp");
parameters.Add(@"c:\*\*\PET_kontener.shp");
parameters.Add(@"c:\*\*\renewal.dbf");
            IGeoProcessorResult result;
            try
            {
                result = (IGeoProcessorResult)GP.Execute("PET", parameters, null);  // HERE GET THE ERROR
0 Kudos