2

I am new to ArcGIS and stuck with "Error HRESULT E_FAIL has been returned from a call to a COM component." error while converting gdb to geodatabase through Arcgis .net SDK verstion (Arcgis Desktop version 10.3.1). Following are my complete code

using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.esriSystem;
using System.Configuration;
using ESRI.ArcGIS.DataManagementTools;
using ESRI.ArcGIS.Geoprocessor;
using System.Runtime.InteropServices;

namespace Drainage_geodbCreator
{
    class Program
    {

        private static LicenseInitializer m_AOLicenseInitializer = new Drainage_geodbCreator.LicenseInitializer();

        [STAThread()]
        static void Main(string[] args)
        {
            String MXDpath = ConfigurationManager.AppSettings["MXDpath"];
            String geoDBPath = ConfigurationManager.AppSettings["geodatabsePath"];
            int mycheck = Convert.ToInt32(ConfigurationManager.AppSettings["geodatabaseversion"]);
            ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
            //ESRI License Initializer generated code.
            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeStandard },
            new esriLicenseExtensionCode[] { });


            CreateRuntimeContent _CreateRuntimeContent = new CreateRuntimeContent();
            _CreateRuntimeContent.in_map = MXDpath;
            _CreateRuntimeContent.output_folder = geoDBPath;
            _CreateRuntimeContent.extent = "DEFAULT";
            _CreateRuntimeContent.options = "FEATURE_AND_TABULAR_DATA";
            _CreateRuntimeContent.optimize = "NON_OPTIMIZE_SIZE";

            bool rst = false;
            try
            {
                ExceuteGeoProcesser(_CreateRuntimeContent, out rst);
            }
            catch (COMException ce)
            {

            }

            //ESRI License Initializer generated code.
            //Do not make any call to ArcObjects after ShutDownApplication()
            m_AOLicenseInitializer.ShutdownApplication();
        }

        static Boolean ExceuteGeoProcesser(IGPProcess _GPProcess, out Boolean ProcessResult)
        {

            Boolean Rslt = false;

            try
            {
                Geoprocessor _Geoprocessor = new Geoprocessor();
                Guid g = new Guid("5374EC4C-1AA2-4829-A811-DE624ECEC23F");
                Type t = Type.GetTypeFromCLSID(g);
                _Geoprocessor = Activator.CreateInstance(t) as Geoprocessor;
                _Geoprocessor = new Geoprocessor();


                _Geoprocessor.Execute(_GPProcess, null);

                ProcessResult = Rslt;

                return true;

            }
            catch (Exception ex)
            {
                ProcessResult = Rslt;
                return false;
            }

        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.