Publish MXD to server in ArcObjects C#

5243
6
02-09-2011 11:38 AM
EddieJesinsky
New Contributor
Hi,

I have an MXD that I would like to publish to an ArcGIS server using C# ArcObjects (preferably as an MSD). I have been unable to find anything regarding this. Essentially I would like to implement the following ArcPy code in ArcObjects:

arcpy.mapping.ConvertToMSD()
arcpy.mapping.PublishMSDToServer()

Any help would be appreciated! Thanks!
0 Kudos
6 Replies
Venkata_RaoTammineni
Occasional Contributor
Hi,

I have an MXD that I would like to publish to an ArcGIS server using C# ArcObjects (preferably as an MSD). I have been unable to find anything regarding this. Essentially I would like to implement the following ArcPy code in ArcObjects:

arcpy.mapping.ConvertToMSD()
arcpy.mapping.PublishMSDToServer()

Any help would be appreciated! Thanks!


There are very less chance to do that.. I dont think it might happen...
0 Kudos
EddieJesinsky
New Contributor
I was able to call arcpy code from the .NET application like shown at this link: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000m0s000000

However, my current problem is that I suspect that arcpy.mapping.PublishMSDToServer() contains a bug or some undocumented requirement, as when publishing manually, my MSD works correctly, but publishing through that procedure causes incorrect paths to be created and the published MSD does not work.

I'm hoping it is some sort of environment setting rather than a bug, but I suppose this is a question for the arcpy forum.

Any additional assistance would be appreciated!
0 Kudos
nicogis
MVP Frequent Contributor
0 Kudos
EddieJesinsky
New Contributor
you can use code like:
http://www.spoiledtechie.com/post/2010/08/04/How-to-publish-a-ArcMap-to-the-ArcGIS-Servere280a6.aspx and so you can se your properties

For msd see the interface IMSDHelper:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/0012/001200044440000000.htm


I was able to get my combo ArcObjects/ArcPy solution working, but thanks! It is good to have that for future reference.
0 Kudos
EddieJesinsky
New Contributor
I recently rewrote my publishing code from python to C#. However, I have yet to figure out how to convert an mxd to msd using IMSDHelper. If anyone has any suggestions please let me know!

p.s. this does not work:
            IMSDHelper helper = new MSDHelperClass();
            helper.Open(mxdName);
            helper.SaveAs(msdName, false);
0 Kudos
Andréde_Mattos_Ferraz
Occasional Contributor
Try bind license:

RuntimeManager.Bind(ProductCode.Desktop);
                IAoInitialize objAoInitialize;
                objAoInitialize = new AoInitializeClass();
                objAoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
                IMSDHelper helper = new MSDHelperClass();
...


I recently rewrote my publishing code from python to C#. However, I have yet to figure out how to convert an mxd to msd using IMSDHelper. If anyone has any suggestions please let me know!

p.s. this does not work:
            IMSDHelper helper = new MSDHelperClass();
            helper.Open(mxdName);
            helper.SaveAs(msdName, false);
0 Kudos