I have a custom GP tool created that works fine in desktop, i can publish it to server successfully, and i can run it from the server endpoint in desktop and even call it from a web application. The problem is however that on the second execution the tool fails. The error message is:
This is one of the tool output parameters.
Invalid return value: c:\arcgisserver\directories\arcgisjobs\solveroute_gpserver\j206d69d70deb45f48030116282263aa5\scratch\scratch.gdb\SHORTEST
the output is defined as:
IGPParameterEdit3 outputParameter = new GPParameterClass(); outputParameter.DataType = new GPFeatureRecordSetLayerTypeClass(); outputParameter.Direction = esriGPParameterDirection.esriGPParameterDirectionOutput; outputParameter.DisplayName = "Shortest Route Results"; outputParameter.Name = "shortest_routes"; outputParameter.ParameterType = esriGPParameterType.esriGPParameterTypeDerived; parameters.Add(outputParameter);
I can see the job id on the path changes on each invocation but so not sure why its failing. Next call gives:
Invalid return value: c:\arcgisserver\directories\arcgisjobs\solveroute_gpserver\jb73331a1e1324bc2b44b2c6d98baed7a\scratch\scratch.gdb\SHORTEST
If I restart server it all works again for one execution.
Anyone have any tips on what you need to do to make this work?
Ok this was actually an internal problem in the tool. In my case i had 2 c# dictionaries caching information about features (since the model loops over them many times during processing). These dictionaries were not being cleared. On the 2nd invocation of the tool it got the same (not being used) SOC process that was used in the first run. An error was then thrown on adding data to the dictionary as some keys already existed (from invocation 1) causing the model output to never be set (hence the error message on it).
After clearing those dictionaries the error is not thrown and the model now runs repeatedly.
The trick to hunting this all down is to look in the jobs directory for your model C:\arcgisserver\directories\arcgisjobs\[model name] and the messages.xml file in the scratch folder. In there i could see the error about the pre-existing key.
So no special tricks needed to get it working just a user error in the model.