TransWikia.com

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

Geographic Information Systems Asked by Tarragorn on June 7, 2021

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:GISLAB3Post.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

One Answer

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 + "rn");
    for (int i = 0; i < _gp.MessageCount; i++)
        messages.AppendLine(_gp.GetMessage(i));
    throw new Exception(messages.ToString());
}

Answered by danielm on June 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP