Server spatial query COM utility


Purpose
This sample includes a Web application that uses the ArcGIS Server ArcObjects application programming interface (API) to access custom functionality on the server to make a series of fine-grained ArcObjects method calls. It does this by extending the geographic information system (GIS) server with a utility Component Object Model (COM) component that exposes a coarse-grained method to perform the bulk of the ArcObjects work on the server.
 
This sample is divided into two parts: the utility COM component and a .NET Web application. To use this sample, you must have the ArcGIS Server Web Application Developer Framework (ADF) for the Microsoft .NET Framework installed on the Web server machine. You must also have an ArcGIS server to connect to that has a pooled map server object called Yellowstone that is serving the Yellowstone.mxd map document.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample.

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/Yellowstone .
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

At design time
  1. Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
  2. Add the Yellowstone.mxd as a map server object to your GIS server. Sample data is located in <ArcGIS Developer Kit install location>\Samples\data.
  3. In Windows Explorer, navigate to <ArcGIS Developer Kit install location>\Samples\ArcObjectsNET\ServerSpatialQueryCOMUtility.
  4. Open the folder of the language you're going to use: CSharp or VBNet. Note that there are multiple application directories. The VegCOM<language> directory contains the .NET class library project, which references the .NET assembly that contains local ArcObjects implementation code and will be exposed as a COM object. The VegWebApp<language> directory contains the ASP.NET Web application that illustrates how the COM object is used.

Work with the VegCOM<language> class library project
  1. Start Visual Studio and open the ServerCOMUtility2008 solution (VBNet folder contains VB.Net version for the sample and would have prefix _VBNet<vs version> ServerCOMUtility_VBNet2008.sln).
  2. Under the Build menu, click Build Solution. The VegCOM<language>.dll is created in the VegCOM<language>\bin\Debug or VegCOM<language>\bin\Release folder.
  3. Open a Visual Studio command prompt and navigate to the location of the VegCOM<language>.dll. To register the .NET assembly with COM so that it is available to a COM-aware client—such as ArcObjects running in a server object container (SOC) process (ArcSOC.exe)—use the following command: regasm VegCOMCSharp.dll /tlb:VegCOMCSharp.tlb /codebase (assuming you're working with the CSharp version of the sample).
  4. The regasm utility registers the assembly, the /tlb option creates and registers a type library for use by COM clients, and the code base option registers the explicit location of the assembly. The code base option returns a warning indicating that the assembly should be signed. If you sign the assembly, you can place it in the Global Assembly Cache (GAC) and remove the /codebase option when using regasm. To sign the assembly and add it to the GAC, following the steps in the Sign the assembly and add it to the GAC section below.
  5. Register the .NET assembly and type library on the Web server and on the ArcGIS SOC machines. Confirm that the ArcGIS SOC user account has read and execute access on the directory that contains the registered assembly and type library.
  6. To unregister the assembly and type library, use the following command: regasm /unregister VegCOMCSharp.dll.

Sign the assembly and add it to the GAC
  1. Create a strongly named key: sn -k MyKeyPair.snk.
  2. Add or uncomment the following entries to the AssemblyInfo.cs file in the VegCOMCSharp project. Change the path for the AssemblyKeyFile attribute to the key created in the previous step. [assembly: AssemblyDelaySign(false)][assembly: AssemblyKeyFile("C:/temp/MyKeyPair.snk")]
  3. Build the VegCOMCSharp project.
  4. Run the following command: regasm VegCOMCSharp.dll /tlb:VegCOMCSharp.tlb.
  5. Add the assembly to the GAC: gacutil -i VegCOMCSharp.dll.

Work with the VegWebApp<language> Web application project
  1. Copy the VegWebApp<language> folder to c:\inetpub\wwwroot. The <language> variable can be either CSharp or VBNet.
  2. Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services.
  3. In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site, expand Default Web Site, right-click the VegWebApp<language> folder, and click Properties. The Properties dialog box opens.
  4. Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
  5. If not already opened, open ServerCOMUtility2008.sln (assuming the version is CSharp) the VegWebApp<language> solution (for example, VegWebAppCSharp2008.sln) located in c:\inetpub\wwwroot\VegWebApp<language>. Reload the VegWebAppCSharp website, if it appears to be unavailable.
  6. In Solution Explorer, right-click Default.aspx and select Set As Start Page.
  7. Open the Default.aspx page in Design view, open the properties window for the MapResourceManager control, and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog box opens.
  8. Add or change the MapResourceItem to the Yellowstone ArcGIS Server local data source.
  9. If not already added, add a reference to the VegCOM<language>.dll created earlier. This assembly is only used by the client to work with strong type references to ArcObjects running in server context on the GIS server.
  10. If necessary, set the run time identity of the Web application by following one of the next two steps. If not necessary, proceed to step 13.
  11. At design time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At run time, that identity is established by the Web application. Only one identity can be used to define access to ArcGIS Server local data sources in a single Web application. This identity can be explicitly defined when building the Web ADF application in Visual Studio by right-clicking the Web project in Solution Explorer and selecting the Add ArcGIS Identity option. Enter the identity credentials that will be used to access ArcGIS Server local resources at run time. This information is added to the web.config file in a standard ASP.NET identity tag. If the Encrypt identity in web.config check box is checked, the identity tag will be encrypted; otherwise, the username and password are stored as clear text.
  12. Open the web.config file, add an <identity> element in <system.web>, set the impersonate attribute to true, and add a username and password attribute and set them to a valid user account. If you're working with ArcGIS Server local data sources, ensure the account has access to the GIS server resources referenced in the Map control.
  13. Save the project.
  14. Click the Debug drop-down menu and click Start.

At run time
  1. Open a browser and navigate to the Web application uniform resource locator (URL) (for example, http://localhost/VegWebAppCSharp) or open the Web application in Visual Studio.
  2. Enter a distance in meters to search vegetation regions in the Vegetation layer. The default is 10000.
  3. Check the Show Summary Results in a Table box to display the summary statistics for the selected regions. (Pop-up blocker should be turned off to allow the table to be displayed.)
  4. On the toolbar, click the Vegetation Summary Proximity Search Tool and click the map. An animated gif is used to indicate that the application is processing. When finished processing, a circular region on the map is highlighted along the boundary of the features in the Vegetation layer, and the summary statistics are rendered in a table below the table of contents (TOC).

VegCOMCSharp\VegCOMCSharp.csproj COM utility project.
VegCOMCSharp\VegUtils.cs Utility class that performs the bulk of the fine-grained ArcObjects calls in the GIS server.
VegCOMCSharp\VegResults.cs Class that stores and packages results to be passed to the client.
VegWebAppCSharp\Default.aspx Contains Web user interface to interact with server-side code.
VegWebAppCSharp\Default.aspx.cs Code file for the .aspx file. References Web ADF libraries and functionality.
VegWebAppCSharp\App_Code\VegTool.cs Custom class library associated with a tool in the Web application. Calls the custom COM utility in server context and processes the results.
Download the C# files
VegCOM_VBNet\VegCOM_VBNet.vbproj COM utility project.
VegCOM_VBNet\VegUtils_VBNet.vb Utility class that performs the bulk of the fine-grained ArcObjects calls in the GIS server.
VegCOM_VBNet\VegResults_VBNet.vb Class that stores and packages results to be passed to the client.
VegWebAppVBNet\Default.aspx Contains Web user interface to interact with server-side code.
VegWebAppVBNet\Default.aspx.vb Code file for the .aspx file. References Web ADF libraries and functionality.
VegWebAppVBNet\App_Code\VegTool_VBNet.vb Custom class library associated with a tool in the Web application. Calls the custom COM utility in server context and processes the results.
Download the VB.NET files

Download the files for all languages