This documentation is archived and is not being maintained.

IVsaPersistSite.LoadElement Method

Gets the source string previously saved using the IVsaPersistSite.SaveElement method.

[Visual Basic]
Function LoadElement( _
   ByVal name As String _
) As String
string LoadElement(
   string name
String* LoadElement(
   String* name
function LoadElement(
   name : String
) : String;


The name of the code item to be loaded. This can be a null reference when loading the Project file.

Return Value

Returns the contents of the source-code element associated with the name parameter.


Calls to IVsaEngine.SaveSourceState cause the script engine to send a number of items back to the host. These items will usually, but not always, have an associated name. The engine guarantees that it will call back for these same items using these same names when it later calls the IVsaEngine.LoadSourceState method.

The order in which items are saved and loaded is not guaranteed to be the same every time save and load operations occur, and nothing semantic is implied by the order in which items are loaded or saved. It is the host's responsibility to persist and re-load items identically, byte-for-byte, when making calls to SaveSourceState and LoadSourceState.

The name parameter must be the valid name of a previously saved element, or, if you are loading the Project file, it must be a null reference.

The following table shows the exceptions that the LoadElement method can throw.

Exception Type Condition
ElementNotFound There was no element with the given name parameter to load.
ElementNameInvalid The element name is not valid, for example, it contains characters that are not valid.
CallbackUnexpected The call was made outside of a call to the IVsaEngine.LoadSourceState method.
LoadElementFailed The element failed. Check System.InnerException for more information.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

IVsaPersistSite Interface | IVsaPersistSite Members | Microsoft.Vsa Namespace | IVsaEngine.LoadSourceState | IVsaEngine.SaveSourceState