Vous êtes sur la page 1sur 2

How to use the samples http://edndoc.esri.com/arcobjects/9.0/Samples/HowToUseDotNetSamples.

htm

ArcGIS SDK
Samples
How to use the .NET samples
This topic discusses compiling .NET solutions and registering .NET components with COM. For more information on adding and
removing ArcGIS application customizations, please see How to use the COM samples.
Compiling .NET Solutions
Plugging .NET Components into ArcGIS Applications

Compiling .NET Solutions


All of the .NET samples require compilation before they can be used. It is easiest to compile the solutions using Visual
Studio.NET 2003.
Open the solution file (.sln) using Visual Studio.NET 2003
Check the solution configuration, decide if you want to build the solution in debug or release mode.
From the 'Build' menu, select 'Rebuild Solution'.
Compiling the solution will generate a dll or exe depending on the the project type.
If the sample produces a dll it will likely additinally generate and register a tlb so the components can work with COM
interop.

Plugging .NET Components into ArcGIS Applications


.NET samples that extend an ArcGIS application such as a custom ArcCatalog command and ArcMap Edit Task need to
register themselves with COM and in the appropriate component category.

Registering .NET Components for COM


All of the .NET samples that use COM interop will already have the 'Register for COM Interop' property sent to True which tells
the compiler to additionally generate a TLB and register it with COM. To check a project's settings, select 'Project Properties'
from the 'Project' menu and then look at the Build property under 'Configuration Properties'. The very last item is 'Register for
COM Interop' and this property should be set to True if the component is a dll that extends an ArcGIS application such as a
custom command or edit task in ArcMap. If this setting is incorrect, please reset it accordingly and recompile the sample.

1 of 2 5/27/2011 11:50 PM
How to use the samples http://edndoc.esri.com/arcobjects/9.0/Samples/HowToUseDotNetSamples.htm

You can register a .NET solution with COM manually using RegAsm.exe which is part of the .NET SDK. The following command
line shows an example.
regasm EditTools.dll /tlb:EditTools.tlb /codebase

Registering Components in Componet Categories


Most of the .NET samples that must be registered in a specific component category have code that automatically performs this
operation whenever the assembly is registered with COM. These samples make use of the ESRI.ArcGIS.Utility namespace which
has classes with static functions to register and unregister components in each component category. The sample code excerpt
below gives an example of this.

[Guid("74b3d982-e4ae-4817-8315-6f025cc270df")]
public sealed class AngleAngleTool: BaseTool
{
[ComRegisterFunction()]
static void Reg(String regKey)
{
MxCommands.Register(regKey);
}

[ComUnregisterFunction()]
static void Unreg(String regKey)
{
MxCommands.Unregister(regKey);
}
If the sample you are working with does not have these functions you must manually register the sample in the appropriate
component category use Categories.exe.
Fore more information on using Categories and adding and removing items from the ArcGIS applicstions, see How to use the
COM samples and the documentation on using Categores.exe.

Send feedback on this page

2 of 2 5/27/2011 11:50 PM

Vous aimerez peut-être aussi