Saturday, May 16, 2009

How to develop backward compatible ArcGIS application?

This post will describe a technique for developing ArcGIS Desktop (or Engine) customizations that are backwardly compatible.

Let's say you develop a custom toolbar for ArcGIS Desktop on a computer that has ArcGIS Desktop 9.2 sp4 installed.  When that toolbar is deployed to other computers then you may get mixed results.  The toolbar will work on computers with 9.2 sp4, 9.2 sp5, 9.2 sp6 and 9.3 but will barf on computers with 9.0, 9.1, 9.2, 9.2 sp1, 9.2 sp2 and 9.2 sp3.

Notice that by default all customizations are upwardly compatible.  This is because ESRI installs publisher policy files into the GAC so that assembly references are automatically redirected to the current version.


But how can you make your toolbar (developed on 9.2 sp4) run on older versions of ArcGIS Desktop?  If you want your toolbar to run on 9.2, 9.2 sp1, 9.2 sp2, 9.2 sp3 then you can:

  1. Compile the toolbar on a computer with 9.2 (no service packs),
  2. Force your project to reference older 9.2 ESRI assemblies.

Obviously the first option requires you to maintain a historic version of ArcGIS Desktop.  This may be inconvenient and possibly not the most efficient use of a computer.  This problem is magnified if you want to deploy a customization that is compatible with older versions like say 9.0 or 9.1.

The second option is the best that I have discovered.  After the initial setup, it only requires minor changes to your .NET projects.  Below I will describe the setup needed to create a customization that supports ArcGIS Desktop 9.2, 9.2 sp1-6 and 9.3.

On any computer:

  1. Install Microsoft .NET 2.0,
  2. Install ArcGIS Desktop 9.2 (do NOT install any service packs),
  3. Copy of the DotNet folder to a location that is accessible to your development computer. Rename the folder to "DotNet92".
    (e.g. copy C:\Program Files\ArcGIS\DotNet to \\ server\files\DotNet92)

On your development computer:

  1. Copy the 9.2 dotnet folder to your development computer
    (e.g. \\ server\files\DotNet92 to C:\Program Files\ArcGIS\DotNet92)

    The ArcGIS Installation Folder

In your Microsoft Visual Studio projects:

  1. Open the project that contains references to the ESRI assemblies.  The path name of the assembly reference should point to the DotNet folder in the ArcGIS Installation folder.

  2. In the project properties, click the Reference Paths tab.  Click the ellipse button to navigate to and select the new DotNet92 folder (ie C:\Program Files\ArcGIS\DotNet92).  Click the Add Folder button to add the path name to the list of reference paths.

  3. Save the project.  Restart Microsoft Visual Studio and re-open the project.  If you re-examine the reference paths they should now be directed to the new 9.2 (no sp) assemblies in the DotNet92 folder that you copied from another computer.

The customizations that you developed on this computer are now backwardly compatible to ArcGIS Desktop 9.2 (no sp) and above.  This same technique can be used to create customizations that are backwardly compatible with older versions of ArcGIS Desktop (or Engine) such as 9.0 or 9.1.  Due to assembly changes at 9.0, this technique cannot be used to create customizations that are backwardly computer to pre-9.0 versions like 8.1, 8.2 or 8.3.

One important considering when compiling against an older assembly is that you cannot take advantage of new features.  For example, if you compile a project against 9.1 assemblies then it can be safely run on computers with 9.2 and 9.3 but you will be unable to use new functionality available in those versions.

Technorati Tags: ,,

No comments:

Post a Comment