danihmoran

Cannot QI IPMFPublish

Discussion created by danihmoran on Aug 1, 2013
Latest reply on Feb 28, 2014 by banone77
Hi, I'm trying to run this sample to create a PMF file from a C# console application
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/PublishMap/004800000077000000/
but I get the following error in this line
IPropertySet settings = publishMaps.GetDefaultPublisherSettings();

[ATTACH=CONFIG]26394[/ATTACH]
According to this object model I should be able to do the QI but it's not working
http://resources.arcgis.com/en/help/arcobjects-net/pdf/PublisherObjectModel.pdf
Any help will be welcome
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
            AoInitialize aoi = new AoInitialize();
            esriLicenseProductCode productCode = esriLicenseProductCode.esriLicenseProductCodeBasic;
            //if (aoi.IsProductCodeAvailable(productCode) == esriLicenseStatus.esriLicenseAvailable)
            //{
            //    aoi.Initialize(productCode);
            //}
            esriLicenseExtensionCode extensionCode = esriLicenseExtensionCode.esriLicenseExtensionCodePublisher;
            if (aoi.IsExtensionCodeAvailable(productCode,extensionCode) == esriLicenseStatus.esriLicenseAvailable)
            {
                aoi.Initialize(productCode);
                aoi.CheckInExtension(extensionCode);
            }

            string folderName = System.IO.Path.GetRandomFileName();
            string folderPath = System.IO.Path.Combine("C:\\temp\\Factory\\", folderName);

            System.IO.Directory.CreateDirectory(folderPath);
            string mxdPath = System.IO.Path.Combine(folderPath, "PublishedMap.mxd");
            IMapDocument md = new MapDocument();
            md.New(mxdPath);
            IMap defaultMap = md.get_Map(0);
                        
            #region create PMF
            IPMFPublish publishMaps = new PublisherEngineClass();
            string pmfPath = System.IO.Path.Combine(folderPath, "PublishedMap.pmf");
            ESRI.ArcGIS.esriSystem.IArray orderedMaps = new ESRI.ArcGIS.esriSystem.Array();
            IPropertySet settings = publishMaps.GetDefaultPublisherSettings();
            //Loop over all the maps in the map document and each one to an Array object
            for (int i = 0; i <= md.MapCount - 1; i++)
            {
                orderedMaps.Add(md.get_Map(i));
            }
            publishMaps.Publish(md.PageLayout, md.ActiveView, null, true, pmfPath);

            
            aoi.CheckOutExtension(extensionCode);}

Attachments

Outcomes