Special
Getting Started with Geoprocessing and ArcObjects in .NET
By Chad D. Cooper, GISP, Southwestern Energy Company
What’s that?
You say you want to do some geoprocessing and maybe even some ArcObjects programming using .NET, but just
aren’t sure where to begin? Visual Studio and the whole “.NET Framework” thing are somewhat
intimidating, aren’t they? If you are not a programmer by training, you sure can be. Namespaces, classes, assemblies, methods, references, solutions… it’s enough to scare anyone not familiar with it. But have
running
no fear. You
—yes you—
can be up
with your very own
.NET geoprocessing application
in no time.
and
What You Will Need
• Notepad (or any text editor) and a command prompt. • Microsoft .NET Framework 2.0 or higher (www.microsoft.com/net/). • Microsoft Visual Studio 2005/2008 (Visual C# Express version available free at www.microsoft.com/express/download/). • An ArcSDE connection, either enterprise or workgroup (optional). • Exercise archive gpandnet.zip, downloaded from ArcUser Online. This archive contains the source code and the listings in a PDF for easy reference when reading this article and the file geodatabase with the sample data.
Why Use the .NET Framework for Geoprocessing? At ArcGIS 9.2, Esri introduced the Geoprocessor .NET assembly, which opened up the geoprocessing toolbox to .NET developers. There are several reasons you might want to use the .NET Framework for your geoprocessing tasks. Maybe your company’s IT department is already a .NET shop. The .NET Framework is enterprise tested and accepted. If you have non-GIS .NET developers, they can be a valuable resource to you when learning the ins and outs of .NET programming. .NET solutions are also extremely scalable. The entire library of over 30,000 ArcObjects components is exposed to you (more on this later), providing you have low-level access to the very objects that the core geoprocessing tools and framework are built with. As we will soon see, communication with the geodatabase is well integrated. Last but not least, .NET applications are fast and efficient.
Getting Started Before you proceed, you need to open the listing files in the exercise archive downloaded from ArcUser Online so you can refer to them. Next, verify that you have the Microsoft .NET Framework installed. To find out if you have .NET Framework version 2.0 or greater installed, go to C:\WINDOWS\Microsoft.NET\Framework. If you have a v2.xx folder there, you already have the .NET Framework 2.0 installed (you may have several folders here, ranging from versions 1.x up to 3.5). If you do not have a licensed version of Visual Studio 2005/2008 Professional, Microsoft provides a lightweight but fully functional version for both the VB.NET and C# languages. To follow along with the examples in this article, download and install Visual C# 2008 Express Edition. Installing Visual Studio 2005 (any licensing level) will also install the .NET Framework 2.0, while installing Visual Studio 2008 (also any licensing level) will install the 3.x .NET Framework. To make compiling at the command line a little easier, set up a Continued on page 38
www.esri.com
ArcUser Spring 2010 37