Debugging IGPFunction

134
4
02-18-2011 05:52 AM
BerendVeldkamp
Occasional Contributor II
Hi all,

I developed a custom tool for ArcGIS Desktop (implementing IGPFunction). Now this seems to works fine, the only problem is that I cannot debug the Execute() method. The actual execution works, but a breakpoint that I set inside the method is never hit. The only workaround I found so far is to put System.Diagnostics.Debugger.Break(); inside the Execute method: This will fire up a 2nd instance of Visual Studio, in which I can debug properly.

I was wondering if there's an easier way to do this.
0 Kudos
4 Replies
StevePiche
New Contributor
Please ensure your geoprocessing is not launched in the background, in a separate thread.

In ArcMap select Geoprocecssing->Geoprocessing Options. In the Background Processing option, disable the checkbox. This should enable you to hit your breakppoints.
0 Kudos
BerendVeldkamp
Occasional Contributor II
That makes perfect sense. Thanks.
0 Kudos
anthonybaker
New Contributor
This is just what I was looking for but it did not work for me.  I am using 10.1 and have created custom geoprocessing tools that depend on a second dll.  It would be great to debug this but it is impossible to get a break point to hit.

Any help would be great.

As a second question, the dll actually loads when I call it in the main thread but there is no evidence that it loads in the execution thread.  Very strange.

Anthony
0 Kudos
FreddieGibson
Regular Contributor II
I've found that inserting the following code into your solution will help with debugging custom GPFunctions.  This line will prompt you to start a session of Visual Studio and allow you to step through your code.

System.Diagnostics.Debugger.Launch();

I just used this the other week against a custom GP function I built and place the code within its execution method.
0 Kudos