I would like to know how can I find out if the layer IDs are fixed in mxd through ArcObjects? I usually use the code below to find the layer ids in mxd:
IMapDocument mapDocument = new MapDocumentClass(); <BR />mapDocument.Open("C:\\Temp\\MyProject.mxd"); <BR />IMap b = mapDocument.get_Map(0); <BR />ILayerExtensions c = b.get_Layer(0) as ILayerExtensions; <BR />IServerLayerExtension g = c.get_Extension(0) as IServerLayerExtension; <BR /> <BR />IPropertySet psN = new PropertySet(); <BR />psN.GetProperty("ServiceLayerID");
But when the ids are not fixed the returned Layer ID is wrong, because it follows the order of the layers included in the mxd.
By fixed ids i mean the configuration of Data Frame Properties General tab, when you check the box "Allow assignement of unique numeric IDs for map service publishing"