I have an ArcMap extension in which I'm trying to persist a string value. When the document is saved, the public member m_LayerName in the application extension class is not being persisted. Either it's not being written to the stream or it's not being loaded correctly once the document is reopened. I'm not sure what I'm doing wrong. The Save and Load events are definitely being executed appropriately, but no data is being saved. This is my first attempt at persisting data with an extension so I'm missing something. Below is the relevant code.
Public m_LayerName As String
...
Public ReadOnly Property ID() As ESRI.ArcGIS.esriSystem.UID Implements ESRI.ArcGIS.esriSystem.IPersistVariant.ID
Get
Dim typeID As UID = New UIDClass()
typeID.Value = Me.GetType().GUID.ToString("B")
Return typeID
End Get
End Property
Public Sub Load(ByVal Stream As ESRI.ArcGIS.esriSystem.IVariantStream) Implements ESRI.ArcGIS.esriSystem.IPersistVariant.Load
m_LayerName = CStr(Stream.Read())
Marshal.ReleaseComObject(Stream)
End Sub
Public Sub Save(ByVal Stream As ESRI.ArcGIS.esriSystem.IVariantStream) Implements ESRI.ArcGIS.esriSystem.IPersistVariant.Save
Stream.Write(m_LayerName)
Marshal.ReleaseComObject(Stream)
End Sub