This document is archived and information here might be outdated.  Recommended version.


Binary compatibility (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Getting started with ArcObjects in .NET > Binary compatibility

Binary compatibility


About binary compatibility

Most ArcGIS developers are familiar with binary compatibility. A component has binary compatibility with a previous version of the same component, if clients compiled against one version run against the new version without the client needing to be recompiled. Each component is associated with various globally unique identifiers (GUIDs), such as the class ID, interface ID, and type library ID. Maintaining the same GUIDs between component versions indicates that the versions are binary compatible.
To maintain binary compatibility in .NET, you can use the GuidAttribute class to manually specify a class ID for your class. By specifying a GUID, you control when that GUID changes. If you do not specify a GUID, the type library exporter automatically generates one when you first export your components to the Component Object Model (COM). Although the exporter generally keeps using the same GUIDs on subsequent exports, this behavior is not guaranteed. Specify GUIDs for any class that you expose to the COM including any class that is inside a project that is registered for COM interop.
In Visual C++, developers control the GUIDs in a component by specifying them in the project's Interface Definition Language (IDL) file, helping to control binary compatibility.
The following code example shows a GUID attribute being applied to a class. You can use the ESRI GuidGen add-in for Visual Studio .NET to apply this attribute to an existing class with a new GUID.
[C#]
[GuidAttribute("9ED54F84-A89D-4fcd-A854-44251E925F09")]
public class SampleClass
{
    // 
}
[VB.NET]
<GuidAttribute("9ED54F84-A89D-4fcd-A854-44251E925F09")> _
               Public Class SampleClass
    '
End Class
Alternatively, if you are working in Visual Basic .NET (VB .NET), you can use the ComClass attribute instead. This attribute can be used to specify GUIDs for the class, the default interface, and the default events interface. You can add a new ComClass to your project by right-clicking the project in the Solution Explorer and selecting Add New Item, then choosing ComClass on the Add New Item dialog box. This not only applies the attribute but also generates and adds new GUIDs for use in the attribute. Alternatively, you can apply the attribute to an existing class, as shown in the following code example. For more information on different ways you can generate new GUIDs, see Using ArcObjects (COM-based) in .NET.
[VB.NET]
<ComClass("B676A49F-2672-42ea-A378-20C17D1F2AFF", _
          "5A90404F-8D1A-4b77-8F3F-C347A97FA34C", _
          "58C9B6E4-B4F3-48dc-862A-181E566C4A31")> _
          Public Class SampleClass
    '
End Class


See Also:

Using ArcObjects (COM-based) in .NET