What is the recommended way to execute .NET C# code from ArcGIS Pro Python?

05-28-2019 12:16 AM
New Contributor II

I am writing a ArcGIS Pro 2.3 AddIn, which has a few RibbonMenu button that will load up some Geoprocessing tools from a custom Python Toolbox. However, some of the scripts will require to call back into C, C++ and C# to do processing. The C and C++ code is easy enough to do using the 'ctypes' module, which is already part of ArcGIS Pro Python environment. But to interface to C# code, I have been unable to work out how to successfully do this.

I've been hunting around for a few days now, attempting to find the best / recommended approach for calling C# code from with Python.

Even though I followed many articles and suggestions I found scattered around the web, I have repeated hit a wall.

The 'pythonnet' package seems to have the most elegant and simplified way of doing it. But, 'pythonnet' is not one of the available python module shipped with ArcGIS Pro Python.

So my question is, how do I do it, constrained within the ArcGIS Pro Python installation / environment?

Is it even possible?

Or do I need to install the 'pythonnet'  package using 'conda' and 'pip', into the arcgispro-py3 environment?


0 Replies