<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Geoprocessing COMException when running my own script. in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessing-comexception-when-running-my-own/m-p/192775#M5031</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Found the solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* use the name of the tool in the properties-&amp;gt;general tab, and not the label in the toolbox&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* use a an IVariantArray paramter, even if there are no parameters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Solution found here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/28884-Execute-Custom-Tool-Obeject-Reference-Not-Set-for-instance-of-Object?highlight=execute+python+script"&gt;http://forums.arcgis.com/threads/28884-Execute-Custom-Tool-Obeject-Reference-Not-Set-for-instance-of-Object?highlight=execute+python+script&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Apr 2013 13:12:28 GMT</pubDate>
    <dc:creator>DietmarPalmetzhofer</dc:creator>
    <dc:date>2013-04-02T13:12:28Z</dc:date>
    <item>
      <title>Geoprocessing COMException when running my own script.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessing-comexception-when-running-my-own/m-p/192773#M5029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have searched a lot of forums looking for answers but none have helped so far.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to run my own script ( a dummy empty one for now) with geoprocessing in Visual studio 2010 using c# and ArcDesktop 10.&amp;nbsp; When I ran this with the "Buffer_analysis" built in tool and some different parameters it worked fine.&amp;nbsp; When I run my own script (which i know it sees as i print the tools out) i can't even get gp.GetMessage(0) error messages, they just come up blank.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my c#.net code: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;using ESRI.ArcGIS.Geoprocessing;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GeoProcessor gp = new GeoProcessor();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ESRI.ArcGIS.esriSystem.AoInitialize ao = null;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RuntimeManager.Bind(ProductCode.Desktop);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ao = new AoInitializeClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; esriLicenseStatus licStatus = ao.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);&amp;nbsp; //Ive also tried arcEditor liscence&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ao.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine("License Checkout successful.");&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.OverwriteOutput = true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.AddToolbox(@"C:\MyToolbox.tbx");&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; IGpEnumList tools = gp.ListTools("*");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; string tool = tools.Next();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; while (tool != "")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(tool);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tool = tools.Next();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IVariantArray parameters = new VarArrayClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parameters.Add(@"C:\Custom_Menu\shape.shp");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.Execute("test", parameters, null);//*********************************this gives the error***************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;catch... Debug.WriteLine(gp.GetMessage(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my "test.py" script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import arcpy module&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage( "\nDone")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't get it.&amp;nbsp; Please help...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 18:12:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessing-comexception-when-running-my-own/m-p/192773#M5029</guid>
      <dc:creator>magdakosior</dc:creator>
      <dc:date>2012-07-04T18:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing COMException when running my own script.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessing-comexception-when-running-my-own/m-p/192774#M5030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am having the same problem. Did you ever solve it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Didi&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Apr 2013 12:53:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessing-comexception-when-running-my-own/m-p/192774#M5030</guid>
      <dc:creator>DietmarPalmetzhofer</dc:creator>
      <dc:date>2013-04-02T12:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing COMException when running my own script.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessing-comexception-when-running-my-own/m-p/192775#M5031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Found the solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* use the name of the tool in the properties-&amp;gt;general tab, and not the label in the toolbox&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* use a an IVariantArray paramter, even if there are no parameters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Solution found here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/28884-Execute-Custom-Tool-Obeject-Reference-Not-Set-for-instance-of-Object?highlight=execute+python+script"&gt;http://forums.arcgis.com/threads/28884-Execute-Custom-Tool-Obeject-Reference-Not-Set-for-instance-of-Object?highlight=execute+python+script&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Apr 2013 13:12:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessing-comexception-when-running-my-own/m-p/192775#M5031</guid>
      <dc:creator>DietmarPalmetzhofer</dc:creator>
      <dc:date>2013-04-02T13:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing COMException when running my own script.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessing-comexception-when-running-my-own/m-p/192776#M5032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I did resolve it though I can't point it to a specific thing that I changed.&amp;nbsp; My code looks pretty much the same but with a lot of testing I realized that somewhere along the line I lost the ability to run this in debug mode (as in it fails right away when it hits gp.execute).&amp;nbsp; When I deploy it and run it as a tool it seems to work fine.&amp;nbsp; I also had some issues working with scripts off a network drive (versus the C drive).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The one thing that I can recommend is to be meticulous about the number of parameters being passed in and the amount that the script expects. If all fails try to re-write the script from a new empty file and to make sure that the script runs fine on its own.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh yah and I noticed that instead of using GeoProcessor I later used Geoprocessor (with a small p).&amp;nbsp; One is geoprocessing and one is geoprocessor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am having the same problem. Did you ever solve it?&lt;BR /&gt;Thanks,&lt;BR /&gt;Didi&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 18:35:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessing-comexception-when-running-my-own/m-p/192776#M5032</guid>
      <dc:creator>magdakosior</dc:creator>
      <dc:date>2013-04-03T18:35:21Z</dc:date>
    </item>
  </channel>
</rss>

