using the following code:
MgSiteConnection con = new MgSiteConnection();
con.Open(new MgUserInformation(sessionID));
//get the map
MgSite site = con.GetSite();
MgResourceService rs = (MgResourceService)con.CreateService(MgServiceType.ResourceService);
MgResourceIdentifier mapID = new MgResourceIdentifier("Session:" + sessionID + "//" + mapName + "." + MgResourceType.Map);
MgMap map = new MgMap();
map.Open(rs, mapID);
//get a feature service
MgFeatureService ftr = (MgFeatureService)con.CreateService(MgServiceType.FeatureService);
MgLayerCollection colLayers = map.GetLayers();
The last line gives the following exception:
OSGeo.MapGuide.MgInvalidOperationException: The requested operation is invalid.
- MgMapBase.GetLayers line 117 file
c:\build_bond_area\mapguide_open_source_v1.2\build_13.7\mgdev\common\platformbase\MapLayer/MapBase.cpp
- MgMap.UnpackLayersAndGroups line 640 file
c:\build_bond_area\mapguide_open_source_v1.2\build_13.7\mgdev\common\mapguidecommon\MapLayer/Map.cpp
--- End of inner exception stack trace ---