IGPUtilities.DecodeRasterLayer() crashes when 2 layers has same name

Discussion created by Oyvind.Idlandgeodata-no-esridist Employee on Feb 15, 2013
Latest reply on Feb 15, 2013 by Oyvind.Idlandgeodata-no-esridist
I got a case here, where two layers has the same name. One of them is a raster layer, the other one is a feature layer.

The raster layer is a parameter in a GP tool. When using it as an argument in DecodeRasterLayer(),I get an exception with
this message: "HRESULT E_FAIL has been returned from a call to a COM component"

This happens only if I run the tool as a background process. Otherwise, it works fine.

Before calling DecodeRasterLayer(), I yield the layer data type via AddMessage(). In both cases (background and foreground),
I get correct datatype (Name = "GPRasterLayer", DisplayName = "Raster Layer").

Its probably not a good practice to have duplicate layer names, but what users do is outside my control..

Is there something that can be done here ? (Except loop through the layers and look for duplicate names,
and then quit the tool with a a message that tells the user to rename the layer..

- Oyvind