AnsweredAssumed Answered

ApplySymbologyFromLayer GeoProcessing Tool

Question asked by bulla_b on Jun 19, 2019
Latest reply on Mar 4, 2020 by bulla_b



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.




                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;