This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ArcObjects namespaces > Server > ESRI.ArcGIS.Server > Interfaces > IS > IServerContext Interface > IServerContext.LoadObject Method (ArcObjects .NET 10.5 SDK) |
Create an object in the server context from a string that was created by saving an object using SaveObject.
[Visual Basic .NET] Public Function LoadObject ( _ ByVal str As String _ ) As Object
[C#] public object LoadObject ( string str );
[C++]
HRESULT LoadObject(
BSTR str,
LPUNKNOWN* obj
);
[C++]
Parameters str [in] str is a parameter of type BSTR obj [out, retval] obj is a parameter of type LPUNKNOWN
These methods allow you to serialize objects in the server context to strings, then deserialize them back into objects. Any object that supports IPersistStream can be saved and loaded using these methods. These methods allow you to copy objects between contexts. For example, if you use a GeocodeServer object to locate an address, then you want to draw the point that GeocodeAddress returns on your map, you need to copy the point into your MapServer's context.
Another important use of these methods is to manage state in your application while making statless use of pooled server object. A good example of this is in a mapping application. The initial session state for all users is the same and is equal to the map descriptor for the map server object. Each user can then change map descriptor properties such as the extent and layer visibility, which need to be maintained in the users session state. The application does this by saving a serialized map descriptor as part of each users session state. Using the serialized string representation allows the application to take advantage of the standard session state management facilities of the web server. The application uses the LoadObject and SaveObject methods to reconstitute the sessions map descriptor whenever it needs to make edits to it in response to user changes or whenever it needs to pass the map descriptor to the map server object for drawing the map according to the users specifications.
It's important to note that if you are building a web application using the ESRI web controls, the controls take care of saving and loading the MapDescription for you.