
Deleting or Copying the Runtime Storage Control
It is possible for end users to delete or copy the Runtime Storage Control. The following examples show how the Visual Studio Tools for Office runtime can detect and correct these circumstances.
End User Performs Select All and Presses Delete
The Runtime Storage Control is deleted. However, the control calls the Visual Studio Tools for Office runtime with information that it is about to be deleted. The runtime adds a new instance of the control to the document, hooks up to the new event sink, and provides persisted information.
End User Performs Select All, Then Copies and Pastes into the Same Document
There are now two Runtime Storage Controls. However, the runtime checks whether there are multiple instances of the control. If there are, it deletes the extra instances.
End User Performs Select All, then Copies and Pastes into a Different Document that Has Managed Code Extensions
There are two Runtime Storage Controls claiming to contain the primary stored information for the document. However, a unique identifier (GUID) is created for the control when it is embedded in the document at design time. This GUID is also embedded in the custom document property _AssemblyLocation. Any Runtime Storage Control in the document must also have this GUID. If an extra Runtime Storage Control is found in the document at load time, it is deleted from the document if the GUID does not match the one stored in the document.
End User Performs Select All, then Copies and Pastes into a New Blank Document
There is now a new document with an unused Runtime Storage Control. Without the proper customizations in the document, the control does not do anything. However, it still takes up space in the document.