<?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: Any way to check whether a COM ArcObjects object is already released? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527318#M14229</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Personally, I don't think you should care whether it has been released or not after the fact, because you would be the person who is releasing it intentionally or via the the way you are structuring your code.&lt;BR /&gt;[/url]&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Just because I am releasing it intentionally, I need to care. Because the current way I am structuring the code doesn't support double releasing. Releasing a released COM object will throw exception.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Aug 2012 17:04:59 GMT</pubDate>
    <dc:creator>SuiHuang</dc:creator>
    <dc:date>2012-08-03T17:04:59Z</dc:date>
    <item>
      <title>Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527315#M14226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everybody:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I found that after an ArcObject COM object is release, some operations such as checking interface cannot be performed on it and otherwise it will throw exception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Is there any way for me to detect whether the object has already been release? I am trying not to use the TRY-CATCH pair to handle this logic...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;**************** Released twice by my utility function ******&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IPoint obj = new PointClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ReleaseObjects(obj);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ReleaseObjects(obj);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;**************** Utility functions *********&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void ReleaseObjects(params object[] comObjList)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (object obj in comObjList)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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 (obj != null)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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 (obj is System.Collections.IEnumerable)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; ReleaseComs(obj as IEnumerable);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; Marshal.ReleaseComObject(obj);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void ReleaseComs(IEnumerable Objects)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (object obj in Objects)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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 (obj != null)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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 (obj is IEnumerable)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; ReleaseComs(obj as IEnumerable);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; Marshal.ReleaseComObject(obj);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Aug 2012 17:02:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527315#M14226</guid>
      <dc:creator>SuiHuang</dc:creator>
      <dc:date>2012-08-02T17:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527316#M14227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there any way for me to detect whether the object has already been release?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;What are you trying to do?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If .NET Garbage collection works the same way as it does in Java, then when an object variable goes out scope, or you set it to null or you assign it another reference, then the object becomes eligible for garbage collection, but you don't know when exactly that happens in the run time environment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Personally, I don't think you should care whether it has been released or not after the fact, because you would be the person who is releasing it intentionally or via the the way you are structuring your code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe this link describes what you want to do:&amp;nbsp; &lt;/SPAN&gt;&lt;A href="http://edndoc.esri.com/arcobjects/9.2/NET/fe9f7423-2100-4c70-8bd6-f4f16d5ce8c0.htm#ReleaseComObject"&gt;http://edndoc.esri.com/arcobjects/9.2/NET/fe9f7423-2100-4c70-8bd6-f4f16d5ce8c0.htm#ReleaseComObject&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 13:18:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527316#M14227</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2012-08-03T13:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527317#M14228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using releaseComObject is necessary in .NET code because some objects' reference count don't decrement when they go out of scope and don't get collected in GarbageCollection.&amp;nbsp; This is a problem for cursor because you can exceed the number of open cursors you are allowed to have.&amp;nbsp; It is also a problem with featureclasses and workspaces and other geodatabase objects that maintain locks until they are explicitly release.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you set your variable to null after calling the release you should be able to test to see if the variable is null and avoid calling it a second time.&amp;nbsp; Aside from that I would only suggest keeping a tighter control on the variables to avoid release being called a an object separated from the RCW.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 16:08:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527317#M14228</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2012-08-03T16:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527318#M14229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Personally, I don't think you should care whether it has been released or not after the fact, because you would be the person who is releasing it intentionally or via the the way you are structuring your code.&lt;BR /&gt;[/url]&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Just because I am releasing it intentionally, I need to care. Because the current way I am structuring the code doesn't support double releasing. Releasing a released COM object will throw exception.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 17:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527318#M14229</guid>
      <dc:creator>SuiHuang</dc:creator>
      <dc:date>2012-08-03T17:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527319#M14230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Using releaseComObject is necessary in .NET code because some objects' reference count don't decrement when they go out of scope and don't get collected in GarbageCollection.&amp;nbsp; This is a problem for cursor because you can exceed the number of open cursors you are allowed to have.&amp;nbsp; It is also a problem with featureclasses and workspaces and other geodatabase objects that maintain locks until they are explicitly release.&lt;BR /&gt;If you set your variable to null after calling the release you should be able to test to see if the variable is null and avoid calling it a second time.&amp;nbsp; Aside from that I would only suggest keeping a tighter control on the variables to avoid release being called a an object separated from the RCW.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you! Seems then assigning null value and avoid calling a second time are the only available ways to go.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 17:06:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527319#M14230</guid>
      <dc:creator>SuiHuang</dc:creator>
      <dc:date>2012-08-03T17:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527320#M14231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Just because I am releasing it intentionally, I need to care. Because the current way I am structuring the code doesn't support double releasing. Releasing a released COM object will throw exception.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;If you, as the programmer, decided to release an object reference, why do you want to know if it has been released or not?&amp;nbsp; Create a new object.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 17:25:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527320#M14231</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2012-08-03T17:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527321#M14232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;If you set your variable to null after calling the release you should be able to test to see if the variable is null and avoid calling it a second time.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Not to nitpick, but if you set a reference to null *after* you have explicitly released it, what other value do you expect it to have when you test it for null?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is Sui trying to call a method on that Object just before it is actually killed off?&amp;nbsp; Not a good idea.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 17:31:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527321#M14232</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2012-08-03T17:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527322#M14233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Not to nitpick, but if you set a reference to null *after* you have explicitly released it, what other value to expect it to have when you test it for null?&lt;BR /&gt;&lt;BR /&gt;Is Sui trying to call a method on that Object just before it is actually killed off?&amp;nbsp; Not a good idea.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a sample senario:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;*******************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;List&amp;lt;IFeature&amp;gt; fList = ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;int i = ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeature f = null;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (...)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f = fList&lt;I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else if&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f=...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//release fList&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//release f&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;*******************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the above case if I release everything in fList without assigning null and f=fList&lt;I&gt; was executed, then I will get exception.&lt;/I&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 18:22:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527322#M14233</guid>
      <dc:creator>SuiHuang</dc:creator>
      <dc:date>2012-08-03T18:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527323#M14234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are releasing fList and f at the end of your procedure/function/method - whatever, how are you getting an exception?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, telling us what kind of exception you're getting would help.&amp;nbsp; Is it NullPointerException?&amp;nbsp; AutomationException?&amp;nbsp; something else?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 18:52:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527323#M14234</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2012-08-03T18:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527324#M14235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you are releasing fList and f at the end of your procedure/function/method - whatever, how are you getting an exception?&lt;BR /&gt;&lt;BR /&gt;Also, telling us what kind of exception you're getting would help.&amp;nbsp; Is it NullPointerException?&amp;nbsp; AutomationException?&amp;nbsp; something else?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Idonahue:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; The exception message tells "COM object that has been separated from its underlying RCW cannot be used."&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Any idea? Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 18:22:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527324#M14235</guid>
      <dc:creator>SuiHuang</dc:creator>
      <dc:date>2012-08-08T18:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527325#M14236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For some reason, your statement is leading me to believe that you are releasing an object, then trying to do a method call on that object, but first checking whether the object you released is null, otherwise calling that method on a released object without first re-assigning that released object the value of null is giving you the exception.&amp;nbsp; What do you expect?&amp;nbsp; If you were in Java, assigning an object reference to null would still give you an exception when you tried calling a method on that object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I still don't understand why you are trying to call a method on an object after you've released it.&amp;nbsp; Can anyone explain that to me?&amp;nbsp; I would really like to understand why you are trying to do this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 19:27:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527325#M14236</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2012-08-08T19:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527326#M14237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;For some reason, your statement is leading me to believe that you are releasing an object, then trying to do a method call on that object, but first checking whether the object you released is null, otherwise calling that method on a released object without first re-assigning that released object the value of null is giving you the exception.&amp;nbsp; What do you expect?&amp;nbsp; If you were in Java, assigning an object reference to null would still give you an exception when you tried calling a method on that object.&lt;BR /&gt;&lt;BR /&gt;I still don't understand why you are trying to call a method on an object after you've released it.&amp;nbsp; Can anyone explain that to me?&amp;nbsp; I would really like to understand why you are trying to do this.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The exception is not caused by calling a method of that released COM object, but caused by releasing it again with my generic releasing method... it use "if (obj is IEnumerable)" to check the interface it supports. Because it is already released, the checking will fail in the second call of the releasing method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I decide to resolve this issue by coding carefully, not to release the same COM object twice, even though the logic will be a bit more comoplicated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 21:35:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527326#M14237</guid>
      <dc:creator>SuiHuang</dc:creator>
      <dc:date>2012-08-08T21:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to check whether a COM ArcObjects object is already released?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527327#M14238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The exception is not caused by calling a method of that released COM object, but caused by releasing it again with my generic releasing method... it use "if (obj is IEnumerable)" to check the interface it supports. Because it is already released, the checking will fail in the second call of the releasing method.&lt;BR /&gt;&lt;BR /&gt;Now I decide to resolve this issue by coding carefully, not to release the same COM object twice, even though the logic will be a bit more comoplicated.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set the object to null after the call to ReleaseComObject.&amp;nbsp; After the object is released, it's value isn't null so if you call the method again it will try to release it again.&amp;nbsp; If you set the object to null after releasing it then the next time you call the method it will see the object is null and not try to release it a second time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, as you said, more careful programming is what you really need.&amp;nbsp; You should be releasing objects when you're done with them.&amp;nbsp; This is usually right before they go out of scope so in reality there shouldn't be another place in the code where you would even have access to the object in order to try to release it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2012 12:21:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/any-way-to-check-whether-a-com-arcobjects-object/m-p/527327#M14238</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2012-08-09T12:21:03Z</dc:date>
    </item>
  </channel>
</rss>

