<?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: How to free/release/unload/uncouple Raster from layer? (v100.4 WPF) in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-free-release-unload-uncouple-raster-from/m-p/218673#M2603</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had a similar problem trying to delete files even after clearing the operational layers. Looking through the documentation, I found a note on&amp;nbsp;&lt;A href="https://developers.arcgis.com/net/latest/ios/api-reference/html/M_Esri_ArcGISRuntime_Data_GeoPackage_Close.htm"&gt;GeoPackage.Close()&lt;/A&gt;&amp;nbsp;saying that only after closing the geopackage can an underlying file be deleted/renamed etc. Adding a call to this got my system working. Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Nov 2019 16:51:41 GMT</pubDate>
    <dc:creator>RachaelSmith1</dc:creator>
    <dc:date>2019-11-04T16:51:41Z</dc:date>
    <item>
      <title>How to free/release/unload/uncouple Raster from layer? (v100.4 WPF)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-free-release-unload-uncouple-raster-from/m-p/218671#M2601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is what I would like to do:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a raster layer from a file&lt;/LI&gt;&lt;LI&gt;Add the layer to the map&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; rlayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;RasterLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;Raster&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"C:/...../myraster.tif"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;Regenerate the raster (same filename if possible, but I have some flexibility)&lt;/LI&gt;&lt;LI&gt;Refresh the raster layer with the newly updated raster file (so that the map is updated)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is that the raster file is still in use (presumably a reference held by the layer). So I can't delete the file or rename it. I tried a few things to try to uncouple the raster from the layer, but no luck. For example ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; layers &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; mapVm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;OperationalLayers&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; raster &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; myRasterLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Raster&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

layers&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Remove&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
raster &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍

System&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GC&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Collect&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I even tried to force garbage collection. I think that may have worked once or twice, but I can't replicate it reliably.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried the local server approach in the &lt;CODE class=""&gt;&lt;SPAN class=""&gt;ArcGISRuntime.WPF.Samples.DynamicWorkspaceRaster&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;sample, but same result. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice? Maybe I need to take a different approach?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:40:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-free-release-unload-uncouple-raster-from/m-p/218671#M2601</guid>
      <dc:creator>KeithGemeinhart1</dc:creator>
      <dc:date>2021-12-11T10:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to free/release/unload/uncouple Raster from layer? (v100.4 WPF)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-free-release-unload-uncouple-raster-from/m-p/218672#M2602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Quick bit of additional info. I tried this using LocalServer as it is done in the Dynamic Workspace Raster from the SDK Samples App, and I get similar behavior. The local server holds a reference to the raster even when a new/different raster file is chosen.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2019 18:37:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-free-release-unload-uncouple-raster-from/m-p/218672#M2602</guid>
      <dc:creator>KeithGemeinhart1</dc:creator>
      <dc:date>2019-08-05T18:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to free/release/unload/uncouple Raster from layer? (v100.4 WPF)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-free-release-unload-uncouple-raster-from/m-p/218673#M2603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had a similar problem trying to delete files even after clearing the operational layers. Looking through the documentation, I found a note on&amp;nbsp;&lt;A href="https://developers.arcgis.com/net/latest/ios/api-reference/html/M_Esri_ArcGISRuntime_Data_GeoPackage_Close.htm"&gt;GeoPackage.Close()&lt;/A&gt;&amp;nbsp;saying that only after closing the geopackage can an underlying file be deleted/renamed etc. Adding a call to this got my system working. Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Nov 2019 16:51:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-free-release-unload-uncouple-raster-from/m-p/218673#M2603</guid>
      <dc:creator>RachaelSmith1</dc:creator>
      <dc:date>2019-11-04T16:51:41Z</dc:date>
    </item>
  </channel>
</rss>

