tim2u

How do I create a layer package programmatically with ArcObjects (via ArcEngine.Net)?

Discussion created by tim2u on Dec 12, 2013
Latest reply on Dec 15, 2013 by Hornbydd
I am trying to create a layer package programmatically with an ArcEngine (.Net) application.  The documentation has good information on how to open a package here: http://help.arcgis.com/en/sdk/10.0/Arcobjects_net/conceptualhelp/index.html#//000100000nv8000000.  However, I can't find ANYTHING anywhere showing how to create a layer package. 

My thought was to use the PackageLayer_management call from a geoprocessor object, but I can not get that to work either.  Here is my code for a simple test (I've tried multiple variations with no luck).  I am starting to wonder if PackageLayer_management is even available to ArcEngine.  I am using other ArcToolbox calls following a similiar approach to that below and those work fine.  Any suggestions/examples would be greatly appreciated. 

        public void CreatePackageLayerTest(ILayer SourceLayer, string outputFile, string GeoDBAbsFileName)
        {

            _geoProcessor.SetEnvironmentValue("Workspace", GeoDBAbsFileName);
            _gpParams.Add(SourceLayer);
            _gpParams.Add(outputFile);
            _gpParams.Add("CONVERT");

            try
            {
                _geoProcessor.Execute("PackageLayer_management", _gpParams, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was a GeoProcessing Error." + ex.ToString());
                returnMessages(_geoProcessor);
            }

            _gpParams.RemoveAll();

        }

Outcomes