1

When you run a Python script from ArcObject .net, an error occurs, all parameters are correct. ArcMap 10.6

import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True
env.workspace = arcpy.GetParameterAsText(0)
#"D:\GISLAB3\Post.mdb"
#Result = arcpy.GetParameterAsText(1)
Result = arcpy.GetParameterAsText(1)
#"D:\GISLAB3"
Hous = arcpy.GetParameterAsText(2)
#"Postt" 
arcpy.FeatureClassToShapefile_conversion(Hous, Result)
c#
 private void button1_Click(object sender, EventArgs e)
 {
 IGeoProcessor2 gp = new GeoProcessorClass();
 gp.AddToolbox("D:/GISLAB3/Scripts.tbx");
 IVariantArray parameters = new VarArrayClass();
 parameters.Add("D:/GISLAB3/Post.mdb");
 parameters.Add("D:/GISLAB3");
 parameters.Add("New");
 gp.Execute("lol", parameters, null);
 }

enter image description here

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Apr 8, 2019 at 17:30

1 Answer 1

1

Wrap your call to Geoprocess.Execute in a try catch and get the output messages. It will likely give you a more useful error:

try
{
 _gp.Execute(process, null);
}
catch (Exception e)
{
 StringBuilder messages = new StringBuilder("Error running " + process.ToolName + "\r\n");
 for (int i = 0; i < _gp.MessageCount; i++)
 messages.AppendLine(_gp.GetMessage(i));
 throw new Exception(messages.ToString());
}
answered Apr 8, 2019 at 20:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.