4

I am trying to publish an arcobjects C# executable as a gpservice. We did this in 10.0 by adding it to a toolbox and hitting publish. Using ArcCatalog in 10.1 you must first run the script before you can 'Share as a Geoprocessing Service'.

I've run the GP tool successfully and have tried both 'Publish to Server' and 'Save as a Service Definition' file. It won't let me go any further though. It comes back with Script Syntax Error Line: 1 - which leads me to believe it is trying to parse the executable as a python script.

Does anyone know how to overcome this? And better yet is there any way to publish a GP service without running it first?

1
  • I've got someone from Esri support helping me with this, this week. I'll post the solution or workaround when/if one is found.
    – dubvfan87
    Commented Jun 26, 2012 at 13:12

3 Answers 3

2

As a worst case you could wrap it in Python, call the executable with a subprocess in the wrapper, and publish the wrapper as a GP service.

1
  • 1
    That would certainly work. We found a way to get around 'Share as Service'. You can just create a dummy python script that takes in your params and then replace the script after it is published as a GP service. The published script will be in: .../directories/arcgisoutput/arcgisinput/...
    – dubvfan87
    Commented Jun 26, 2012 at 13:15
1

Well here is the response I got from Esri tech support:

Hi Matt,
I tested on my side and confirmed that .exe file is no long supported as to publish as a GP tool.
I've attached the error information I got when trying to publish a .exe file as a GP tool.

It seems that in 10.1 you have to reproduce your code in a python script code to publish the tool to your Server.
I'm sorry for all the inconvenience this will bring.
Let me know if you have any further question.
Regards,

Esri Tech

Solution:

Wrap the exe file in its own toolbox and call the the toolbox from another python script in a toolbox. So you need 2 toolboxes one with the python wrapper and the other with exe gp tool. Use the import toolbox function in the wrapper python script.

1

Admittedly a bit 'hacky' - I've used this approach with great success.

Basically, I just create a dll (via Class Library project in visual studio) that encapsulates all of my ArcObjects needs. I then add a reference to that dll using Python.NET and it works more or less like native python class.

1
  • Interesting, I've never considered IronPython with ArcObjects. I think we are a bit C# committed at this point though.
    – dubvfan87
    Commented Jul 11, 2012 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.