<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Persisting data for Add-In extension ( 10.4 ) in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174605#M1048</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Mark..(same hat &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/grin.png" /&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error occurred right on&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14709427515179616 jive_text_macro" data-renderedposition="86_8_1332_16" jivemacro_uid="_14709427515179616"&gt;&lt;P&gt;PersistHelper.Load &amp;lt; MyPersistentData &amp;gt; (inStrm, &lt;SPAN class="keyword"&gt;ref&lt;/SPAN&gt; _data);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According the ESRI resources for the PersistenceHelper class , the second parameter is an out&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/004v/004v00000378000000.htm" title="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/004v/004v00000378000000.htm"&gt;http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/004v/004v00000378000000.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tried not new'ing variable without any success.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Aug 2016 19:23:24 GMT</pubDate>
    <dc:creator>MarkLopez2</dc:creator>
    <dc:date>2016-08-11T19:23:24Z</dc:date>
    <item>
      <title>Persisting data for Add-In extension ( 10.4 )</title>
      <link>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174603#M1046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm currently converting some COM extensions to add-ins for our ArcMap 10.4 deployment but am stuck with a persistence issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following the sample from here:&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Add_in_coding_patterns/0001000000zz000000/" title="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Add_in_coding_patterns/0001000000zz000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcObjects 10 .NET SDK Help&lt;/A&gt; &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="kwrd"&gt;private&lt;/SPAN&gt; MyPersistentData _data;

&lt;SPAN class="kwrd"&gt;protected&lt;/SPAN&gt; &lt;SPAN class="kwrd"&gt;override&lt;/SPAN&gt; &lt;SPAN class="kwrd"&gt;void&lt;/SPAN&gt; OnLoad(Stream inStrm)
{
&lt;SPAN class="rem"&gt;// Initialize the struct.&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; _data.Location = &lt;SPAN class="str"&gt;""&lt;/SPAN&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; _data.Point = &lt;SPAN class="kwrd"&gt;new&lt;/SPAN&gt; ESRI.ArcGIS.Geometry.PointClass();

&amp;nbsp;&amp;nbsp;&amp;nbsp; PersistHelper.Load &amp;lt; MyPersistentData &amp;gt; (inStrm, &lt;SPAN class="kwrd"&gt;ref&lt;/SPAN&gt; _data);
}

&lt;SPAN class="kwrd"&gt;protected&lt;/SPAN&gt; &lt;SPAN class="kwrd"&gt;override&lt;/SPAN&gt; &lt;SPAN class="kwrd"&gt;void&lt;/SPAN&gt; OnSave(Stream outStrm)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; PersistHelper.Save &amp;lt; MyPersistentData &amp;gt; (outStrm, _data);
}

[Serializable()]
&lt;SPAN class="kwrd"&gt;private&lt;/SPAN&gt; &lt;SPAN class="kwrd"&gt;struct&lt;/SPAN&gt; MyPersistentData
{
&lt;SPAN class="kwrd"&gt;public&lt;/SPAN&gt; &lt;SPAN class="kwrd"&gt;string&lt;/SPAN&gt; Location;
&lt;SPAN class="kwrd"&gt;public&lt;/SPAN&gt; ESRI.ArcGIS.Geometry.PointClass Point;
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Utilizing the exact code in my add-in extension , I'm getting an error on the OnLoad routine.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Cannot create uninitialized instance of types requiring managed activation.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:01:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174603#M1046</guid>
      <dc:creator>MarkLopez2</dc:creator>
      <dc:date>2021-12-11T09:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Persisting data for Add-In extension ( 10.4 )</title>
      <link>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174604#M1047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm a little confused by the error message you're getting, but my guess is that it's because the second parameter to Load is a &lt;STRONG&gt;ref&lt;/STRONG&gt; parameter, not an &lt;STRONG&gt;out&lt;/STRONG&gt; parameter.&amp;nbsp; Try new'ing up the _data member:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="keyword" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699;"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699;"&gt;override&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699;"&gt;void&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt; OnLoad(Stream inStrm)&lt;/SPAN&gt;
&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;{&lt;/SPAN&gt;
&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _data = new MyPersistentData();&lt;/SPAN&gt;
&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _data.Location = "";&lt;/SPAN&gt;
&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _data.Point = new ESRI.ArcGIS.Geometry.PointClass();&lt;/SPAN&gt;

&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;PersistHelper.Load &amp;lt; MyPersistentData &amp;gt; (inStrm, &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699;"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt; _data);&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="color: #000000; font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif;"&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it were an out parameter, then Load would initialize the object instead of you doing it in OnLoad.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, the problem could be something completely different given the bit about "managed activation".&amp;nbsp; What specific line is the error from?&amp;nbsp; The call to Load or setting Location or Point?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:01:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174604#M1047</guid>
      <dc:creator>MarkRubelmann</dc:creator>
      <dc:date>2021-12-11T09:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Persisting data for Add-In extension ( 10.4 )</title>
      <link>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174605#M1048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Mark..(same hat &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/grin.png" /&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error occurred right on&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14709427515179616 jive_text_macro" data-renderedposition="86_8_1332_16" jivemacro_uid="_14709427515179616"&gt;&lt;P&gt;PersistHelper.Load &amp;lt; MyPersistentData &amp;gt; (inStrm, &lt;SPAN class="keyword"&gt;ref&lt;/SPAN&gt; _data);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According the ESRI resources for the PersistenceHelper class , the second parameter is an out&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/004v/004v00000378000000.htm" title="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/004v/004v00000378000000.htm"&gt;http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/004v/004v00000378000000.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tried not new'ing variable without any success.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 19:23:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174605#M1048</guid>
      <dc:creator>MarkLopez2</dc:creator>
      <dc:date>2016-08-11T19:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Persisting data for Add-In extension ( 10.4 )</title>
      <link>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174606#M1049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmm...&amp;nbsp; I followed your link but it looks to me like it wants a ref.&amp;nbsp; It would give you a compiler error if your code isn't using the correct one.&amp;nbsp; Speaking of which, is that a compiler error you're getting or a runtime exception?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You said you've "also tried not new'ing".&amp;nbsp; Did you try including the new like I had in my first comment?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 19:37:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174606#M1049</guid>
      <dc:creator>MarkRubelmann</dc:creator>
      <dc:date>2016-08-11T19:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Persisting data for Add-In extension ( 10.4 )</title>
      <link>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174607#M1050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry.. I meant to say that I did try newing the variable. This is a runtime error. Also like to point out that if I change the object to have two string properties.. instead of the pointclass then everything works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2016 12:29:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174607#M1050</guid>
      <dc:creator>MarkLopez2</dc:creator>
      <dc:date>2016-08-12T12:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Persisting data for Add-In extension ( 10.4 )</title>
      <link>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174608#M1051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only other suggestion I can think of is changing MyPersistentData's Point variable to an ESRI.ArcGIS.Geometry.IPoint instead of PointClass.&amp;nbsp; If that doesn't work, then I'm afraid we've ventured deeper into ArcObjects than I've ever gone.&amp;nbsp; Do you need to have one of their COM objects inside the class you're trying to persist or is this simply to get their sample code up and running?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:42:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174608#M1051</guid>
      <dc:creator>MarkRubelmann</dc:creator>
      <dc:date>2016-08-12T13:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Persisting data for Add-In extension ( 10.4 )</title>
      <link>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174609#M1052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually I'm trying to persist custom fillsymbols (SimpleFillSymbol). BinaryFormatter didn't like serializing them so eventually found the PersistenceHelper class. While the helper class works with a single symbol it didn't work with a custom object holding multiple symbols. Thank you for looking into this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2016 14:05:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/persisting-data-for-add-in-extension-10-4/m-p/174609#M1052</guid>
      <dc:creator>MarkLopez2</dc:creator>
      <dc:date>2016-08-12T14:05:21Z</dc:date>
    </item>
  </channel>
</rss>

