Running python script from VB.net

3836
1
01-22-2014 12:17 PM
AZendel
Occasional Contributor III
I'm trying to implement the code in the following article:

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/Leveraging_ArcPy_in_a_...

As the article recommends, I passed the following to the function: "python C:\temp\Del_tLUMPCCases_KNO.py".  This executes the script and it gets the job done, but I get a Windows error that pops up and states that the Python.exe has crashed: check online for a solution and close or close.  This could cause the user to think that the entire vb.net .exe process has also crashed

I've tried just the path to my python script:  Dim command As String = "C:\temp\Del_tLUMPCCases_KNO.py"

I've tried calling the python exe and then the path to my script: Dim command As String = "C:\Python27\ArcGISx6410.2\python.exe C:\temp\Del_tLUMPCCases_KNO.py".  This works without crashing when executed through the cmd prompt or pasting that string into Windows Explorer.  When I do this, it launches the python console with the heading "C:\Python27\ArcGISx6410.2\python.exe", so I presume that's the correct executable to try to use (I'm using a 64bit Win7 machine).   And when executed this way, the python script functions properly, which is to delete a table from a geodatabase - without a notification that python.exe has crashed.

Are there other ways to simulate pasting the above examples into the cmd prompt - but from vb.net? It needs to be synchronous - this python must complete before my vb.net exe goes to the next line of code.

The reason I'm using python is because I tried just about every way to call a geoprocessing tool or model using ESRI.ArcGIS.Geoprocessing.IGeoProcessor2 and ESRI.ArcGIS.Geoprocessor.Geoprocessor.   Every time I delete a table through these methods, my vb.net exe crashes.   I execute the tools in a Try Catch block and it never invokes the code in the catch block.  The exe just shutsdown immediately.
0 Kudos
1 Reply
DuncanHornby
MVP Notable Contributor
Your comment about the IGeoprocessor2 blowing up every time, what version of ArcGIS are you using and do you have any service packs installed? By the way you need to be mentioning that in any developer based question as this information is critical. For example ESRI introduced a bug with SP1 for 10.1 if you used IDataStatistics...