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 = MapView.Active.Map;
pBar.Minimum = 0;
pBar.Maximum = map.Layers.Count;
this.Cursor = Cursors.Wait;
GPExecuteToolFlags flags = GPExecuteToolFlags.GPThread;
foreach (Layer layer in map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
var gpresult = await Geoprocessing.ExecuteToolAsync("ApplySymbologyFromLayer_management", new string[] { layer.Name.ToString(), @"K:\DSM Shared\ArcMap Symbology\10.2 Schema\Editing Symbols\" + layer.Name.ToString() + ".lyr" }, null, null, flags);
pBar.Value = pBar.Value + 1;
}
Solved! Go to Solution.
Hi Uma,
Now it works.
Thank you for your patience.