AnsweredAssumed Answered

Persisting data for Add-In extension ( 10.4 )

Question asked by markl1995 on Aug 11, 2016
Latest reply on Aug 12, 2016 by markl1995

Hi Everyone,

 

I'm currently converting some COM extensions to add-ins for our ArcMap 10.4 deployment but am stuck with a persistence issue.

 

Following the sample from here:ArcObjects 10 .NET SDK Help

private MyPersistentData _data;

protected override void OnLoad(Stream inStrm)
{
// Initialize the struct.
    _data.Location = "";
    _data.Point = new ESRI.ArcGIS.Geometry.PointClass();

    PersistHelper.Load < MyPersistentData > (inStrm, ref _data);
}

protected override void OnSave(Stream outStrm)
{
    PersistHelper.Save < MyPersistentData > (outStrm, _data);
}

[Serializable()]
private struct MyPersistentData
{
public string Location;
public ESRI.ArcGIS.Geometry.PointClass Point;
}

 

Utilizing the exact code in my add-in extension , I'm getting an error on the OnLoad routine.

  • Cannot create uninitialized instance of types requiring managed activation.

 

Saving the custom object works fine and it also load fine when change the object to a just a point.I'm needing to saving multiple items hence the need for a custom object. I'm not sure how I can use the PersistenceHelper class to save everything that's needed.

Outcomes