I have created a custom model tool in ArcMap 10.2.2. If we run this tool on ArcMap, we noticed that the tool is working fine. where as if we call the same in Arc Objects under Geo-processing tool, it is throwing an error as shown below
Error Message
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(@"C:\temp\IDW\New\ShapeFiles", 0);
IFeatureClass pSourceFC = featureWorkspace.OpenFeatureClass("BA31_3429_2016");
Geoprocessor GP = new Geoprocessor();
GP.SetEnvironmentValue("Extent", "1745440.000 5922240.000 1745920.000 5921520.000");
GP.AddToolbox(@"D:\temp\My_Tools.tbx");
IVariantArray parameters = new VarArrayClass();
parameters.Add(pSourceFC);
parameters.Add("Shape.Z");
parameters.Add(txtoutput.Text + "\\" + pSourceFC.AliasName + ".asc");
parameters.Add(1);
GP.Execute("IDWtoASCII", parameters, null);
Model Builder