English

Problem: Cannot debug .NET components in ArcGIS applications using Visual Studio .NET 2003

Description

Custom components such as commands or tools can be debugged by running an ArcGIS application by way of the Visual Studio .NET 2003 debugger. If the full or beta version of the .NET Framework 2.x is installed, one of the following behaviors occurs when an ArcGIS application is used as the debug target in Visual Studio .NET 2003:

· The selected ArcGIS application starts normally. However, when the custom component runs, the ArcGIS application exits immediately, the debug session in Visual Studio terminates and Visual Studio returns to development mode.

· The splash screen of the selected ArcGIS application displays. However, the application exits with no errors, the debug session in Visual Studio terminates and Visual Studio returns to development mode.

· The selected ArcGIS application does not start at all nor is the splash screen displayed and Visual Studio returns to development mode.

Note:
If the components are built independently and the ArcGIS application is started outside of a debug session, the components operate as expected.

Note:
ArcGIS versions 9.0 and 9.1 support development with Visual Studio 2003, which targets version 1.1 of the .NET Framework. The .NET Framework 2.x can be installed with previous versions of the .NET Framework.

This information only applies to ArcGIS versions 9.0 and 9.1.

Cause

When an unmanaged application such as ArcMap needs to load a managed component written in .NET and registered for Component Object Model (COM) interoperability, the unmanaged application loads the most recent version of the .NET framework.

The debugger in Visual Studio 2003 is only able to work with .NET framework versions 1.0 or 1.1. When it attempts to connect to the application which has loaded version 2.0 of the .NET framework, the debugger is unable to continue and therefore the session is terminated.

The default behavior of the .NET framework is the same regardless of the version against which the .NET components were built. It is important to consider that the application may load many different components that may have been built against different versions of the .NET framework.

Solution or Workaround

Each process, whether managed or unmanaged, can only host a single version of the .NET framework for its lifetime. It is not possible to change the loaded version at runtime; however, the .NET framework version to be loaded can be specified by using an application configuration file, which must be present before the application starts up.

To debug .NET components in ArcGIS applications using Visual Studio .NET 2003 on machines with the .NET Framework 2.0 installed, create application configuration files for the ArcGIS applications, forcing the use of version 1.1 of the .NET framework.

The following method creates an example configuration file for ArcMap. Apply this method to create a configuration file for the other ArcGIS applications.

Note:
If the use of the .NET framework 1.1 in the ArcGIS applications is forced, this prevents the debugging of the component in Visual Studio .NET 2005. To debug in Visual Studio 2005, remove the application configuration file(s).

  1. Start Windows Explorer and locate the folder containing the application. Typically for ArcMap, this folder will be C:\Program Files\ArcGIS\Bin.
  2. Create a new empty file by right-clicking in the file list pane in Windows Explorer and selecting New.
  3. Name the file using the following naming convention:

    <ApplicationName>.<ApplicationExtension>.config

    For example, the ArcMap file is called 'ArcMap.exe.config'. Click Yes in the dialog box that warns about changing the file extension.
  4. Open the newly created .config file and paste the following contents:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <startup>
    <supportedRuntime version="v1.1.4322" />
    </startup>
    </configuration>

  5. Save and close the file.