<?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 IWorkspaceExtensionControl.Shutdown - Memory corruption in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceextensioncontrol-shutdown-memory/m-p/307800#M8005</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Windows, ArcGIS 9.3.1 SP2, Oracle 11.2, .NET C# 3.5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a simple workspace extension class that tracks current workspaces.&lt;/P&gt;&lt;P&gt;We have found that if you access any IWorkspace (or other interface it's cast to) property or method while processing the Shutdown callback it will corrupt memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The doc's say:&lt;/P&gt;&lt;P&gt;"The &lt;STRONG&gt;Shutdown&lt;/STRONG&gt; method informs the workspace extension that the workspace has been released by all clients and is &lt;SPAN style="color: #3d3d3d;"&gt;&lt;STRONG&gt;about&lt;/STRONG&gt; &lt;/SPAN&gt;to go away. In response, the workspace extension should release its reference on the workspace helper. Any subsequent calls by the application to the workspace extension should return an error."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the shutdown we were getting the IWorkspace from the cached IWorkspaceHelper, then just getting the Name from the IWorkspace (or cast to IVersion to get VersionName) to write to a log.&amp;nbsp; After doing this we would get random, mainly "pure call", errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Believe should either:&lt;/P&gt;&lt;P&gt;1) If not supposed to use IWorkspace in Shutdown the WorkspaceHelper.Workspace should return null.&lt;/P&gt;&lt;P&gt;2) If supposed to be able to use it then fix the memory corruption bug.&lt;/P&gt;&lt;P&gt;and update the documenation accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am wondering if this is specific to .NET i.e. maybe the .NET wrapper is no longer usable even if the underlying COM object is.&lt;/P&gt;&lt;P&gt;Am posting in-case others get "pure call" exceptions as this was a fairly trickly bug to find.&lt;/P&gt;&lt;P&gt;Curious if still an issue under 10.x.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 10 Jan 2015 18:08:43 GMT</pubDate>
    <dc:creator>ChrisKushnir</dc:creator>
    <dc:date>2015-01-10T18:08:43Z</dc:date>
    <item>
      <title>IWorkspaceExtensionControl.Shutdown - Memory corruption</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceextensioncontrol-shutdown-memory/m-p/307800#M8005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Windows, ArcGIS 9.3.1 SP2, Oracle 11.2, .NET C# 3.5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a simple workspace extension class that tracks current workspaces.&lt;/P&gt;&lt;P&gt;We have found that if you access any IWorkspace (or other interface it's cast to) property or method while processing the Shutdown callback it will corrupt memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The doc's say:&lt;/P&gt;&lt;P&gt;"The &lt;STRONG&gt;Shutdown&lt;/STRONG&gt; method informs the workspace extension that the workspace has been released by all clients and is &lt;SPAN style="color: #3d3d3d;"&gt;&lt;STRONG&gt;about&lt;/STRONG&gt; &lt;/SPAN&gt;to go away. In response, the workspace extension should release its reference on the workspace helper. Any subsequent calls by the application to the workspace extension should return an error."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the shutdown we were getting the IWorkspace from the cached IWorkspaceHelper, then just getting the Name from the IWorkspace (or cast to IVersion to get VersionName) to write to a log.&amp;nbsp; After doing this we would get random, mainly "pure call", errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Believe should either:&lt;/P&gt;&lt;P&gt;1) If not supposed to use IWorkspace in Shutdown the WorkspaceHelper.Workspace should return null.&lt;/P&gt;&lt;P&gt;2) If supposed to be able to use it then fix the memory corruption bug.&lt;/P&gt;&lt;P&gt;and update the documenation accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am wondering if this is specific to .NET i.e. maybe the .NET wrapper is no longer usable even if the underlying COM object is.&lt;/P&gt;&lt;P&gt;Am posting in-case others get "pure call" exceptions as this was a fairly trickly bug to find.&lt;/P&gt;&lt;P&gt;Curious if still an issue under 10.x.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Jan 2015 18:08:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceextensioncontrol-shutdown-memory/m-p/307800#M8005</guid>
      <dc:creator>ChrisKushnir</dc:creator>
      <dc:date>2015-01-10T18:08:43Z</dc:date>
    </item>
  </channel>
</rss>

