Select to view content in your preferred language

Cannot QI IPMFPublish

1194
5
08-01-2013 09:35 AM
DanielMoran
Emerging Contributor
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/0048000000770...
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);}
0 Kudos
5 Replies
MelitaKennedy
Esri Notable Contributor
Not a programmer! But don't you have the CheckInExtension and CheckOutExtension methods switched?

Melita
0 Kudos
NeilClemmons
Honored Contributor
Not sure why you would get an error on that line.  I would think you would get a QI error here:
IPMFPublish publishMaps = new PublisherEngineClass();

Also, it looks like you're checking in the publisher license instead of checking it out:
aoi.CheckInExtension(extensionCode);

Perhaps you're getting the error because the extension isn't checked out.
0 Kudos
DanielMoran
Emerging Contributor
Hi, thanks for your answers.
I have corrected the checkin/checkout code lines, but the error persists.
[ATTACH=CONFIG]26423[/ATTACH]
I can verify in ArcGIS Administrator that the extension licence is checked out/in

Also I was modifying "Embed Interop Types" property for ESRI.ArcGIS.Publisher dll, but I get another error, see attached image.
[ATTACH=CONFIG]26424[/ATTACH]

Any help will be welcome.
0 Kudos
NeilClemmons
Honored Contributor
If you have the Embed Interop Types property available, then that means you set your target .NET Framework to 4.0.  You should set it to 3.5 as 4.0 is not supported for ArcObjects (although you can use it at 10.1).  At the very least, the property should be set to False for all ESRI assembly references.
0 Kudos
by Anonymous User
Not applicable
Daniel,
Did you get this resolved?  I am trying the same thing and getting the same results as you.
Thanks,
Dan
0 Kudos