vijaynap79

"QuickExport" geoprocessing tool using arcObjects is throwing error

Discussion created by vijaynap79 on Feb 27, 2011
What could be the problem in bellow code?

public void publishtokml()
        {
            //Create the Geoprocessor object
            IGeoProcessor gp = new GeoProcessorClass();
            try
            {
                gp.SetEnvironmentValue("Workspace", "D:\\KIG");
                gp.OverwriteOutput = true;
              
                //Open a tool by name from a toolbox
                object pGPTool;
                pGPTool = gp.Open("QuickExport");
                IGPTool gpt = pGPTool as IGPTool;

                //Get an array of parameters
                IArray pParamArray;
                pParamArray = gpt.ParameterInfo;

                IGPParameter pParameter;
                IGPParameterEdit pParameterEdit;
                IGPDataType pDataType;

                pParameter = pParamArray.get_Element(0) as IGPParameter;
                pParameterEdit = pParameter as IGPParameterEdit;
                pDataType = pParameter.DataType;
                pParameterEdit.Value = pDataType.CreateValue("d://KIG//DongraliVillage.shp");

                pParameter = pParamArray.get_Element(1) as IGPParameter;
                pParameterEdit = pParameter as IGPParameterEdit;
                pDataType = pParameter.DataType;
                pParameterEdit.Value = pDataType.CreateValue("KML21,d://KIG//don1.kml");

                gpt.Execute(pParamArray, null, null, null);

         

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }

        }


*********************
Error is :

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."


Thanks,
Vijay

Outcomes