<?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: Memory could not be read closing the application in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122946#M3237</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You didn't explain enough about your application to help you with the original error. However, the error you are seeing in your work around is likely due to the way you instantiate the IStyleGallery. It is a singleton object and needs to be created like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Type t = Type.GetTypeFromProgID("esriFramework.StyleGallery");
System.Object obj = Activator.CreateInstance(t);
IStyleGallery sg = obj as IStyleGallery;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000043p000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000043p000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 07:04:24 GMT</pubDate>
    <dc:creator>RichWawrzonek</dc:creator>
    <dc:date>2021-12-11T07:04:24Z</dc:date>
    <item>
      <title>Memory could not be read closing the application</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122945#M3236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I updated my ArcGIS version from 9.3 to 10.0, and now I have always an error when application is closing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;The instruction at "0x7c90100b" referenced memory at "0x294e0a24". The memory could not be "read". Click on OK to terminate the program.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have read that I can solve this error with the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt; protected override void Dispose(bool disposing) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IStyleGallery styleGallery = new StyleGalleryClass() as IStyleGallery;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IntPtr pointer = Marshal.GetComInterfaceForObject(styleGallery, typeof(IStyleGallery));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Common.GIS.GISUtil.releaseCOMObjects(styleGallery);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Close the ARCGIS map license
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GC.Collect();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GC.WaitForPendingFinalizers();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (Exception e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Common.Utilities.LogFile.appendLine_error(e);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; finally
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (disposing &amp;amp;&amp;amp; (components != null))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; components.Dispose();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base.Dispose(disposing);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This Dispose method is the main form's method. However, I am having the following exception on the first line (creating the StyleGalleryClass):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {AC0E9827-91CB-11D1-8813-080009EC732A} failed due to the following error: 80040154&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I can not solve the problem, and I don't have any idea of how to avoid the memory error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone have any idea? Thank you very much in advance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2012 14:53:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122945#M3236</guid>
      <dc:creator>SergioMunoz</dc:creator>
      <dc:date>2012-03-20T14:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Memory could not be read closing the application</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122946#M3237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You didn't explain enough about your application to help you with the original error. However, the error you are seeing in your work around is likely due to the way you instantiate the IStyleGallery. It is a singleton object and needs to be created like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Type t = Type.GetTypeFromProgID("esriFramework.StyleGallery");
System.Object obj = Activator.CreateInstance(t);
IStyleGallery sg = obj as IStyleGallery;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000043p000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000043p000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:04:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122946#M3237</guid>
      <dc:creator>RichWawrzonek</dc:creator>
      <dc:date>2021-12-11T07:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Memory could not be read closing the application</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122947#M3238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for your answer,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I cannot give you more information because I don't have it. Everything was working fine until I updated ArcGIS from 9.3 to 10.0, and now when the application is closed that error appears. However, that error only appears when I execute the application without debugging. If I debug the application, instead of that error the application hangs on, i.e., everything is closed and finished but the application is still running (I suppose that one of the libraries has an active thread or something). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have used this code to know if an unhandled exception is thrown, but everything is fine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionCaptured);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Besides, if I use your code to get the StyleGallery, the t object is null:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Type t = Type.GetTypeFromProgID("esriFramework.StyleGallery");&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I am at the same point &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:04:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122947#M3238</guid>
      <dc:creator>SergioMunoz</dc:creator>
      <dc:date>2021-12-11T07:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Memory could not be read closing the application</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122948#M3239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, I have located exactly where the error is, and it's on the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IMoleSymbol moleSymbol = new MoleMarkerSymbolClass();
&amp;nbsp;&amp;nbsp;&amp;nbsp; moleSymbol.SymbolID = APP6IDSymbol;
&amp;nbsp;&amp;nbsp;&amp;nbsp; moleSymbol.Style = moleSymbologyStyleEnum.moleSSAPP6A;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; IMoleSymbolImportExport pExport = (IMoleSymbolImportExport)moleSymbol;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int handle = pExport.ToBitmapHandle(null, 70, 70);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The last line is the one that is blocking the application and launching the error when it is closed. If I comment it, the application finishes correctly, but it worked on 9.3 version, so I don't know why in 10.0 is crashing...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:04:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122948#M3239</guid>
      <dc:creator>SergioMunoz</dc:creator>
      <dc:date>2021-12-11T07:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Memory could not be read closing the application</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122949#M3240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We have the same problem. See the post named "Exception after stand alone application was closed".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We guess that may be problem in "new" (10) License objects or ... (?).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 10:40:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122949#M3240</guid>
      <dc:creator>MarkMindlin</dc:creator>
      <dc:date>2012-03-21T10:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Memory could not be read closing the application</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122950#M3241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I cannot give you more information because I don't have it. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;You have the source code if you are debugging it so there is a lot you should know about the application. The original post did not let anyone know that this is a standalone application. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;Besides, if I use your code to get the StyleGallery, the t object is null:&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;This is not my code, it is a direct example from Esri from the link I provided, and t is not an object it is a type. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't have the Military Analyst extension so I cannot help with the code you posted but I'm sure it would help other users if you show the part where pExport is instantiated. I deduced that it is probably a IMoleSymbolImportExport object but you are not making it easy for people to help you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 15:52:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-could-not-be-read-closing-the-application/m-p/122950#M3241</guid>
      <dc:creator>RichWawrzonek</dc:creator>
      <dc:date>2012-03-21T15:52:17Z</dc:date>
    </item>
  </channel>
</rss>

