AnsweredAssumed Answered

IPersistVariant::Load not called

Question asked by jospilon on Jul 17, 2012
Latest reply on Sep 11, 2012 by polluxll
Hi,

I have migrated my ArcMap-extension from COM to an add-in. Since then I am having trouble to persist my custom layer to the mxd-document. When I save to a document the IPersistVariant::Save method is called normally, but when I open that document the Load method is not called. Ultimately I added a very simple ILayer implementation to test if the problem was somewhere else in my class, but with this simple test the exact same problem occurs: the save method is called but not the load method.

Does anybody have an idea what could be wrong or a suggesting how to investigate further? Because I am at a dead end here...

This is my test class:

Imports System.Runtime.InteropServices Imports ESRI.ArcGIS.Carto Imports ESRI.ArcGIS.esriSystem Imports ESRI.ArcGIS.Geometry Imports ESRI.ArcGIS.Display  <Guid("E9CB507B-9A23-4272-B4E6-65AE059DEBD4"), ComVisible(True), ClassInterface(ClassInterfaceType.None), ProgId("AnchorPP.TestLayer")> Public Class TestLayer : Implements ILayer, IPersistVariant      Private m_point As IPoint = Nothing     Private m_UID As UID      Public Sub New()         MyBase.New()         m_point = New PointClass()      End Sub      Public ReadOnly Property AreaOfInterest As ESRI.ArcGIS.Geometry.IEnvelope Implements ESRI.ArcGIS.Carto.ILayer.AreaOfInterest         Get          End Get     End Property      Public Property Cached As Boolean Implements ESRI.ArcGIS.Carto.ILayer.Cached         Get             Return False         End Get         Set(ByVal value As Boolean)          End Set     End Property      Public Sub Draw(ByVal DrawPhase As ESRI.ArcGIS.esriSystem.esriDrawPhase, ByVal Display As ESRI.ArcGIS.Display.IDisplay, ByVal TrackCancel As ESRI.ArcGIS.esriSystem.ITrackCancel) Implements ESRI.ArcGIS.Carto.ILayer.Draw          m_point.X = My.Document.ActiveView.Extent.XMin + My.Document.ActiveView.Extent.Width \ 2         m_point.Y = My.Document.ActiveView.Extent.YMin + My.Document.ActiveView.Extent.Height \ 2          Dim simplepointsymbol As New SimpleMarkerSymbol         Dim red As New RgbColor         red.Red = 255          simplepointsymbol.Color = red         simplepointsymbol.Size = 5         simplepointsymbol.Style = esriSimpleMarkerStyle.esriSMSCircle          Display.SetSymbol(simplepointsymbol)         Display.DrawPoint(m_point)      End Sub      Public Property MaximumScale As Double Implements ESRI.ArcGIS.Carto.ILayer.MaximumScale         Get          End Get         Set(ByVal value As Double)          End Set     End Property      Public Property MinimumScale As Double Implements ESRI.ArcGIS.Carto.ILayer.MinimumScale         Get          End Get         Set(ByVal value As Double)          End Set     End Property      Public Property Name As String Implements ESRI.ArcGIS.Carto.ILayer.Name         Get             Return "TestLayer"         End Get         Set(ByVal value As String)          End Set     End Property      Public Property ShowTips As Boolean Implements ESRI.ArcGIS.Carto.ILayer.ShowTips         Get          End Get         Set(ByVal value As Boolean)          End Set     End Property      Public WriteOnly Property SpatialReference As ESRI.ArcGIS.Geometry.ISpatialReference Implements ESRI.ArcGIS.Carto.ILayer.SpatialReference         Set(ByVal value As ESRI.ArcGIS.Geometry.ISpatialReference)          End Set     End Property      Public ReadOnly Property SupportedDrawPhases As Integer Implements ESRI.ArcGIS.Carto.ILayer.SupportedDrawPhases         Get             Return CInt(esriDrawPhase.esriDPGeography)         End Get     End Property      Public ReadOnly Property TipText(ByVal x As Double, ByVal y As Double, ByVal Tolerance As Double) As String Implements ESRI.ArcGIS.Carto.ILayer.TipText         Get          End Get     End Property      Public ReadOnly Property Valid As Boolean Implements ESRI.ArcGIS.Carto.ILayer.Valid         Get             Return True         End Get     End Property      Public Property Visible As Boolean Implements ESRI.ArcGIS.Carto.ILayer.Visible         Get             Return True         End Get         Set(ByVal value As Boolean)          End Set     End Property      Public ReadOnly Property ID As ESRI.ArcGIS.esriSystem.UID Implements ESRI.ArcGIS.esriSystem.IPersistVariant.ID         Get             m_UID = New UID             m_UID.Value = "{" & Me.GetType.GUID.ToString & "}"             Return m_UID         End Get     End Property      Public Sub Load(ByVal Stream As ESRI.ArcGIS.esriSystem.IVariantStream) Implements ESRI.ArcGIS.esriSystem.IPersistVariant.Load          Dim value = Stream.Read      End Sub      Public Sub Save(ByVal Stream As ESRI.ArcGIS.esriSystem.IVariantStream) Implements ESRI.ArcGIS.esriSystem.IPersistVariant.Save          Stream.Write("some value")      End Sub End Class

Outcomes