How to get published GP Service (custom c# tool) to run twice??

1544
3
03-16-2016 10:27 AM
MarkReddick
New Contributor III

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?

thanks

mark

Tags (1)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

the question is marked as assumed answered  ... did you get a resolution to this issue and if so what was it

0 Kudos
MarkReddick
New Contributor III

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.

0 Kudos
DanPatterson_Retired
MVP Emeritus

thanks for the update

0 Kudos