I got a strange issue in GP tool I don't really understand:
In my IGPFunction2.UpdateMessages() method, I use the following code to traverse all layers:
IEnumLayer enumLayer = gpUtils.GetMapLayers();
enumLayer.Reset();
ILayer layer = enumLayer.Next();
while (layer != null)
{
<code here>
layer = enumLayer.Next();
}
The purpose is to look for layers with duplicate names.
This works fine when I don't run the tool in the background. In background mode however, the Execute() method is never triggered.
This seems to happen after enumLayer.Next() is used. When removing the enumLayer.Next() and the code below, it works fine.
There are no error messages or exceptions occuring, and Arc claims that the tool executed succesfully. When calling IGPMessages.AddMessage() as the first action in Exceute(), nothing is yielded.
Any suggestions is appreciated..