Hi,
I'm trying to update the layers of a map by running the ApplySymbologyFromLayer GeoProcessing tool through some .NET code. For a while, there was a reported BUG-000106281 about this, but it is apparently fixed in 2.3.
But.....I still cannot get it to work. Is there something wrong with my code? All of my .lyr files are located on a network drive. I get a NULL Reference Exception at the .ExecuteToolAsync line.
Thanks,
Map map <SPAN class="operator token">=</SPAN> MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">;</SPAN>
pBar<SPAN class="punctuation token">.</SPAN>Minimum <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN>
pBar<SPAN class="punctuation token">.</SPAN>Maximum <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN>Layers<SPAN class="punctuation token">.</SPAN>Count<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>Cursor <SPAN class="operator token">=</SPAN> Cursors<SPAN class="punctuation token">.</SPAN>Wait<SPAN class="punctuation token">;</SPAN>
GPExecuteToolFlags flags <SPAN class="operator token">=</SPAN> GPExecuteToolFlags<SPAN class="punctuation token">.</SPAN>GPThread<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">foreach</SPAN> <SPAN class="punctuation token">(</SPAN>Layer layer <SPAN class="keyword token">in</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> gpresult <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ExecuteToolAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"ApplySymbologyFromLayer_management"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">string</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">{</SPAN> layer<SPAN class="punctuation token">.</SPAN>Name<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">@"K:\DSM Shared\ArcMap Symbology\10.2 Schema\Editing Symbols\" + layer.Name.ToString() + "</SPAN><SPAN class="punctuation token">.</SPAN>lyr" <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN> flags<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
pBar<SPAN class="punctuation token">.</SPAN>Value <SPAN class="operator token">=</SPAN> pBar<SPAN class="punctuation token">.</SPAN>Value <SPAN class="operator token">+</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>