Toolbox tools written in C# instead of Python

1653
3
08-27-2012 07:56 AM
KevinGooss
Occasional Contributor
I seem to recall at some point reading about the possibility of writing python-like script tools in C# instead of python.
Is this possible at 10.1?
Tags (2)
0 Kudos
3 Replies
ModyBuchbinder
Esri Regular Contributor
Hi

This is the example: http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/0001/0001000002r6000000.htm
I do not think it changed from 10.0

Have Fun
Mody
0 Kudos
MattMoyles
New Contributor III
You can use ArcObjects C# geoprocessing tools in ArcDesktop but you cannot publish them to ArcServer starting in 10.1. There is a hack to get passed this using a python script wrapper with the subprocess module. This will redirect stdout from your c# executable so you can still display some messages using Console.WriteLine()

p=subprocess.Popen([
        'c:\path\to\your.exe',
            '-argument1',
            '-argument2',
            'AA',
            '/auto'
        ],
        shell=True,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT)


while True:
    line = p.stdout.readline()
    message = line.rstrip()
    if !message:
        arcpy.AddMessage("[INFO] Tool complete.")
        p.stdout.close()
        break
    else:
        arcpy.AddMessage(message)
0 Kudos
KevinGooss
Occasional Contributor
Humm... that sounds like a licensing nightmare.
reminds me of the old days of using a webservice and automation to open an arcmap process.
0 Kudos