ArcObjects Library Reference  (Carto)    

IMapServerObjects2.RefreshServerObjects Method

Updates the server info based on the current state of the underlying fine-grained objects.

[Visual Basic 6.0]
Sub RefreshServerObjects
[Visual Basic .NET]
Public Sub RefreshServerObjects ( _
)
[C#]
public void RefreshServerObjects (
);
[Java]
public void refreshServerObjects (
)
throws
    IOException,
    AutomationException
[C++]
HRESULT RefreshServerObjects(
void
);

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

Use RefreshServerObjects when you have made changes to the fine-grained ArcObjects and want to apply them to the MapServer object. Keep in mind that this will change the default state of the MapServer object. In order to get the updated MapDescription, you have to call GetServerInfo on IMapServer2 again.

Any custom graphics (IMapDescription2 or IPageDescription) set previous to the RefreshServerObjects call will be lost. You will need to repeat the code for the custom graphics.

RefreshServerObjects does not refresh the extent on IPageDescription . Therefore, if you have zoomed to a particular extent of the page layout using the fine-grained ArcObjects (IActiveView) and you want to apply this extent to the PageDescription, you have to do this manually.

[C#]

The following sample code shows how to change the fine-grained ArcObjects (by adding a new group layer), and apply these changes to the MapServer object using RefreshServerObjects.
It assumes that you are developing an ArcGIS Server application using a ServerContext, and already have a valid ServerContext, MapServer and MapDescription object.

IServerContext serverContext;
IMapServer2 mapServer;
IMapDescription mapDesc;
// Access fine-grained ArcObjects
IMapServerObjects2 mapServerObj = (IMapServerObjects)mapServer;
string strMapName = mapServer.DefaultMapName;
IMap map = mapServerObj.get_Map(strMapName);
// Add a new group layer to map
IGroupLayer groupLayer = serverContext.CreateObject("esriCarto.GroupLayer") as IGroupLayer;
groupLayer.Name = "New Group Layer";
map.AddLayer(groupLayer);
// Apply changes to MapServer object
mapServerObj.RefreshServerObjects();
// Get updated MapServerInfo and MapDescription
IMapServerInfo2 mapServerInfo = mapServer.GetServerInfo(strMapName);
mapDesc = mapServerInfo.DefaultMapDescription;
[Visual Basic 6.0]

The following sample code shows how to change the fine-grained ArcObjects (by adding a new group layer), and apply these changes to the MapServer object using RefreshServerObjects.
It assumes that you are developing an ArcGIS Server application using a ServerContext, and already have a valid ServerContext, MapServer and MapDescription object.


Dim pServerContext as IServerContext
Dim pMapServer as IMapServer2
Dim pMapDesc as IMapDescription2

'Access fine-grained ArcObjects
Dim pMapServerObj As IMapServerObjects2
Set pMapServerObj = pMapServer
Dim strMapName as string
strMapName = pMapServer.DefaultMapName
Dim pMap As IMap
Set pMap = pMapServerObj.Map(strMapName)
    
'Add new group layer to map
Dim pGroupLayer As IGroupLayer
Set pGroupLayer = pServerContext.CreateObject("esriCarto.GroupLayer")
pGroupLayer.Name = "New Group Layer"
pMap.AddLayer pGroupLayer
    
'Apply changes to MapServer object
pMapServerObj.RefreshServerObjects 
    
'Get updated MapServerInfo and MapDescription
Dim pMapServerInfo as IMapServerInfo2
Set pMapServerInfo = pMapServer.GetServerInfo(strMapName)
Set pMapDesc = pMapServerInfo.DefaultMapDescription

See Also

IMapServerObjects2 Interface