Description:
This sample includes a Web application that uses the ArcGIS Server ArcObjects API to access custom functionality on the server to make a series of fine-grained ArcObjects method calls. It does this by extending the GIS server with a utility COM component that exposes a coarse-grained method to perform the bulk of the ArcObjects work within the server.
This sample is divided into two parts: the utility COM component and a .NET Web application. In order to use this sample, you must have the ArcGIS Server Web Application Developer Framework 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.
Sample data location: <ArcGIS install location>\DeveloperKit\SamplesNet\Server\data\Yellowstone
Products: Server: C#, VB.NET
Platforms: WindowsMinimum ArcGIS Release: 9.2 |
How to use:
- Design Time:
- 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.
- Add the Yellowstone.mxd as a map server object to your GIS Server. Sample data is located in <ArcGIS install location>\DeveloperKit\SamplesNet\Server\data
- In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit\SamplesNet\Server\Web_Applications and unzip ArcGIS_Spatial_Query_COM_UtilityCSharp.zip or ArcGIS_Spatial_Query_COM_UtilityVBNet.zip (if available) to a location of your choice. You should see either a CSharp or VBNet folder appear where you unzipped the files.
- In Windows Explorer, open the directory referencing the language of your choice: CSharp or VBNet. Note 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.
- To work with the VegCOM<language> class library project, do the following:
- Launch Microsoft Visual Studio 2005 and open the VegCOM<language> solution (for example, VegCOMCSharp.sln).
-
Under the Build menu, select the "Build Solution" item. If successful, the VegCOM<language>.dll should be created in VegCOM<language>\bin\Debug or VegCOM<language>\bin\Release folder.
-
Open a Visual Studio 2005 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 within a server object container (ArcSOC.exe) process, use the following command (assuming you are working with the CSharp version of the sample):
regasm VegCOMCSharp.dll /tlb:VegCOMCSharp.tlb /codebase
The regasm utility registers the assembly, the /tlb option creates and registers a type library for use by COM clients, and the codebase option registers the explicit location of the assembly. The codebase option will return a warning indicating that the assembly should be signed. If you choose to sign the assembly, you can also 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, do the following:
- Create a strongly named key:
sn -k MyKeyPair.snk
- 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")]
- Build the VegCOMCSharp project.
- Run the following command:
regasm VegCOMCSharp.dll /tlb:VegCOMCSharp.tlb
- Add the assembly to the GAC:
gacutil -i VegCOMCSharp.dll
- The .NET assembly and type library should be registered on the Web server and on the ArcGIS Server Object Container machines. Make sure that the ArcGIS Server Object Container user account has read/execute access on the directory that contains the registered assembly and type library.
- To unregister the assembly and type library, use the following command:
regasm /unregister VegCOMCSharp.dll
- To work with the VegWebApp<language> Web application project, do the following:
- Copy the folder, VegWebApp<language>, to c:\inetpub\wwwroot. The <language> variable may be either CSharp or VBNet.
- Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services
- In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site.
- Expand Default Web Site then right-click the VegWebApp<language> folder and click Properties.
- On the Directory tab, click the Create button in the Application Settings section of this panel. Click OK to dismiss the Properties dialog.
- Launch Microsoft Visual Studio 2005 and open the VegWebApp<language> solution (for example, VegWebAppCSharp.sln) located in c:\inetpub\wwwroot\VegWebApp<language>.
- In the Solution Explorer, right-click Default.aspx and select 'Set As Start Page'.
- Open the Default.aspx page in design view. Open the properties window for the MapResourceManager control. Click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog should display.
- Add or change the MapResourceItem to the Yellowstone ArcGIS Server Local data source.
- 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).
- If necessary, set the runtime identity of the Web application:
- At design-time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At runtime, that identity is established by the Web application. Only one identity can be used to define access to all 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 which will be used to access ArcGIS Server local resources at runtime. This information will be added to the web.config file within a standard ASP.NET identity tag. If the "Encrypt identity in web.config" checkbox is checked, the identity tag will be encrypted, otherwise the username and password will be stored as clear text.
-or-
- Open the web.config file and add an <identity> element within <system.web>. Set the impersonate attribute to "true". Add a userName and password attribute and set them to a valid user account. If working with ArcGIS Server Local data sources, make sure the account has access to the GIS Server resources referenced in the Map control.
- Save the project.
- Click the "Debug" drop-down menu and choose "Start".
- Run time:
- Open a browser and navigate to the Web application URL (for example,
http://localhost/VegWebAppCSharp) -or- start the Web application within Visual Studio 2005.
- Enter a distance in meters to search vegetation regions within the Vegetation layer. The default is 10000.
- To display the summary statistics for the selected regions, check the box next to "Show Summary Results in a Table".
- In the toolbar, click on the tool "Vegetation Summary Proximity Search Tool".
- Click on the map. Note that an animated gif is used to indicate that the application is processing.
- When finished, a circular region in the map should be highlighted along the boundary of the features in the Vegetaion layer. The summary statistics should be rendered in a table below the Toc.
| VegCOMCSharp.csproj |
COM utility project. |
| ArcGIS_Spatial_Query_COM_Utility_CSharp/VegCOMCSharp/VegUtils.cs
|
Utility class which performs the bulk of the fine-grained ArcObjects calls within the GIS Server. |
| ArcGIS_Spatial_Query_COM_Utility_CSharp/VegCOMCSharp/VegResults.cs
|
A class designed to store and package results to be passed to the client. |
| VegWebAppCSharp.sln |
Web application solution. |
| Default.aspx |
Contains Web user interface to interact with server-side code. |
| ArcGIS_Spatial_Query_COM_Utility_CSharp/VegWebAppCSharp/Default.aspx.cs
|
Code file for the aspx file. References Web ADF libraries and functionality. |
| ArcGIS_Spatial_Query_COM_Utility_CSharp/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
| VegCOMVBNet.vbproj |
COM utility project. |
| ArcGIS_Spatial_Query_COM_Utility_VBNet/VegCOMVBNet/VegUtils.vb
|
Utility class which performs the bulk of the fine-grained ArcObjects calls within the GIS Server. |
| ArcGIS_Spatial_Query_COM_Utility_VBNet/VegCOMVBNet/VegResults.vb
|
A class designed to store and package results to be passed to the client. |
| VegWebAppVBNet.sln |
Web application solution. |
| Default.aspx |
Contains Web user interface to interact with server-side code. |
| ArcGIS_Spatial_Query_COM_Utility_VBNet/VegWebAppVBNet/Default.aspx.vb
|
Code file for the aspx file. References Web ADF libraries and functionality. |
| ArcGIS_Spatial_Query_COM_Utility_VBNet/VegWebAppVBNet/App_Code/VegTool.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