ArcObjects Library Reference (Carto)  

IMapServerObjects.RefreshServerObjects Method

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

[Visual Basic .NET]
Public Sub RefreshServerObjects ( _
)
[C#]
public void RefreshServerObjects (
);
[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

See Also

IMapServerObjects Interface

.NET Related Topics

Managing application state |