<?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: Cannot Close/Release  Raster file (TIFF) after removal from layer in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1112443#M10604</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;Try setting the local raster i.e "myRaster" raster object in code above , to null as well. It might be raster object that is perhaps locked.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 29 Oct 2021 15:48:45 GMT</pubDate>
    <dc:creator>PreetiMaske</dc:creator>
    <dc:date>2021-10-29T15:48:45Z</dc:date>
    <item>
      <title>Cannot Close/Release  Raster file (TIFF) after removal from layer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1112004#M10591</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I have an app that generates TIFF file on the fly based on sensor data. I am using a raster layer and colormap renderer to visualize the data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// create a raster from a path to a supported raster format
Raster myRaster = new Raster(vm.RadarLoc.rasterPath);
               
// create a RasterLayer using the Raster
newRasterLayer = new RasterLayer(myRaster);
newRasterLayer.Opacity=0.7;
ApplyColour();

//  newRasterLayer.Renderer = 
MyMapView.Map.OperationalLayers.Add(newRasterLayer);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; When a new set of data is available I remove the Raster from the layers - using&amp;nbsp;MyMapView.Map.OperationalLayers.Remove(newRasterLayer);. I then deference the newRasterLayer. I would hope that the backing file would now have any file handle closed within the ERSI runtime, however if I try to delete it or modify it I cannot because the file is still open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Remove the raster
MyMapView.Map.OperationalLayers.Remove(newRasterLayer);
                    
newRasterLayer= null;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I have not been able to find a way to get the file closed. GCCollect does not help, waiting for a time does not help. Closing the app totally does release it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Added a small demo of the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp; Am I missing a step to get the file released?&lt;/P&gt;&lt;P&gt;c#, SDK WPF Runtime 100.10.0.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 11:04:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1112004#M10591</guid>
      <dc:creator>MarcusJones</dc:creator>
      <dc:date>2021-11-02T11:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Close/Release  Raster file (TIFF) after removal from layer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1112443#M10604</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;Try setting the local raster i.e "myRaster" raster object in code above , to null as well. It might be raster object that is perhaps locked.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 15:48:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1112443#M10604</guid>
      <dc:creator>PreetiMaske</dc:creator>
      <dc:date>2021-10-29T15:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Close/Release  Raster file (TIFF) after removal from layer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1112771#M10611</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;The myRaster variable only has local scope in the event handler and so goes out of scope immediately after the Raster layer has been added. However I have also tried setting it to null and get the same issue with the file remaining open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 08:31:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1112771#M10611</guid>
      <dc:creator>MarcusJones</dc:creator>
      <dc:date>2021-11-01T08:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Close/Release  Raster file (TIFF) after removal from layer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1112991#M10614</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;It's possible that you're unable to delete the raster until .NET garbage collection has run. Try calling the following (one or more times):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;GC.Collect();
GC.WaitForPendingFinalizers();
try
{
    if (File.Exists(rasterFile))
    {
        File.Delete(rasterFile);
    }
}
catch (Exception e)
{
    // TODO...
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 20:37:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1112991#M10614</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2021-11-01T20:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Close/Release  Raster file (TIFF) after removal from layer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1113125#M10615</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thanks for the suggestion. I have tried that - and added a loop in to retry and wait for 1 sec at a time after triggering the garbage collector. However the problem remains.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 09:16:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1113125#M10615</guid>
      <dc:creator>MarcusJones</dc:creator>
      <dc:date>2021-11-02T09:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Close/Release  Raster file (TIFF) after removal from layer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1279549#M11788</link>
      <description>&lt;P&gt;Did you even managed to solve this Marcus? I'm running in exactly the same situation with the 200.0 SDK. I've tried all kinds of solutions. When running from Visual Studio 2022 all runs well but when you build and install the program it runs into this situation. For some reason the Raster is keeping the file locked even though it supposedly is released (after setting the Raster to null and having removed all layers on the map).&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 07:24:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1279549#M11788</guid>
      <dc:creator>RichardFlapper</dc:creator>
      <dc:date>2023-04-18T07:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Close/Release  Raster file (TIFF) after removal from layer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1279555#M11789</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;No, sorry. I couldn't find a way to get the file closed, so I avoided using the same file name and did a tidy up when the application was closed.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 07:53:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1279555#M11789</guid>
      <dc:creator>MarcusJones</dc:creator>
      <dc:date>2023-04-18T07:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Close/Release  Raster file (TIFF) after removal from layer</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1279557#M11790</link>
      <description>&lt;P&gt;Ah, too bad. Guess I'll have to use the same tactic then and use completely random file names. Thanks for replying!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 08:01:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/cannot-close-release-raster-file-tiff-after/m-p/1279557#M11790</guid>
      <dc:creator>RichardFlapper</dc:creator>
      <dc:date>2023-04-18T08:01:34Z</dc:date>
    </item>
  </channel>
</rss>

