ComCompatibleVersionAttribute Classe

Definição

Indica a um cliente COM que todas as classes na versão atual de um assembly são compatíveis com as classes em uma versão anterior do assembly.Indicates to a COM client that all classes in the current version of an assembly are compatible with classes in an earlier version of the assembly.

public ref class ComCompatibleVersionAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
public sealed class ComCompatibleVersionAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ComCompatibleVersionAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
type ComCompatibleVersionAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ComCompatibleVersionAttribute = class
    inherit Attribute
Public NotInheritable Class ComCompatibleVersionAttribute
Inherits Attribute
Herança
ComCompatibleVersionAttribute
Atributos

Exemplos

O exemplo a seguir mostra como especificar a versão 1.0.0.0 do assembly em um assembly com um número de versão mais alto.The following example shows how to specify assembly version 1.0.0.0 in an assembly with a higher version number. Independentemente da nova versão do assembly, todos os CLSIDs no assembly são gerados usando a versão 1.0.0.0 em vez de usar a versão atual do assembly.Regardless of the new assembly version, all CLSIDs in the assembly are generated using version 1.0.0.0 instead of using the current assembly version.

using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;

[assembly: AssemblyVersion("3.0.0.0")];
[assembly: ComCompatibleVersion(1,0,0,0)];
namespace MyNamespace
{
    public ref class TheClass
    {
        // Insert code.
    };
};
using System;
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion("3.0.0.0")]
[assembly: ComCompatibleVersion(1,0,0,0)]
namespace MyNamespace
{
    public class TheClass
    {
        // Insert code.
    }
}
Imports System.Reflection
Imports System.Runtime.InteropServices

<assembly: AssemblyVersion("3.0.0.0")>
<assembly: ComCompatibleVersion(1,0,0,0)>
Namespace MyNamespace
    Public Class TheClass
        ' Insert code.
    End Class
End Namespace

Comentários

Você pode aplicar esse atributo a assemblies.You can apply this attribute to assemblies.

Por padrão, o Tlbexp.exe (tipo de exportador da biblioteca de tipos) usa o número de versão do assembly para calcular os identificadores de classe (CLSIDs).By default, the Tlbexp.exe (Type Library Exporter) uses an assembly's version number to calculate class identifiers (CLSIDs). Todas as classes públicas, visíveis para COM, recebem novos CLSIDs cada vez que você exporta uma nova versão do assembly.All public, COM-visible classes receive new CLSIDs each time you export a new assembly version.

Você pode aplicar o ComCompatibleVersionAttribute atributo para forçar todos os CLSIDs para classes na versão atual de um assembly para serem os mesmos que os CLSIDs para classes em uma versão anterior do assembly.You can apply the ComCompatibleVersionAttribute attribute to force all CLSIDs for classes in the current version of an assembly to be the same as CLSIDs for classes in an earlier version of the assembly. Desde que os CLSIDs permaneçam os mesmos, um aplicativo COM herdado poderá usar a versão mais recente de um assembly compatível depois que você desinstalar o assembly original.As long as the CLSIDs remain the same, a legacy COM application can use the later version of a compatible assembly after you uninstall the original assembly. Se você aplicar o System.Runtime.InteropServices.GuidAttribute a uma classe para definir explicitamente seu CLSID, o ComCompatibleVersionAttribute não terá nenhum efeito.If you apply the System.Runtime.InteropServices.GuidAttribute to a class to explicitly set its CLSID, the ComCompatibleVersionAttribute has no effect.

As propriedades desse atributo se combinam para formar as quatro partes de uma versão de assembly.The properties of this attribute combine to form the four parts of an assembly version. Sempre especifique a versão mais baixa para a qual o assembly atual é compatível com versões anteriores para que a versão seja usada para calcular todos os CLSIDs no assembly.Always specify the lowest version that the current assembly is backward compatible with so that version is used to calculate all CLSIDs in the assembly.

Construtores

ComCompatibleVersionAttribute(Int32, Int32, Int32, Int32)

Inicializa uma nova instância da classe ComCompatibleVersionAttribute com os números da versão principal, da versão secundária, de build e de revisão do assembly.Initializes a new instance of the ComCompatibleVersionAttribute class with the major version, minor version, build, and revision numbers of the assembly.

Propriedades

BuildNumber

Obtém o número de build do assembly.Gets the build number of the assembly.

MajorVersion

Obtém o número de versão principal do assembly.Gets the major version number of the assembly.

MinorVersion

Obtém o número de versão secundária do assembly.Gets the minor version number of the assembly.

RevisionNumber

Obtém o número de revisão do assembly.Gets the revision number of the assembly.

TypeId

Quando implementado em uma classe derivada, obtém um identificador exclusivo para este Attribute.When implemented in a derived class, gets a unique identifier for this Attribute.

(Herdado de Attribute)

Métodos

Equals(Object)

Retorna um valor que indica se essa instância é igual a um objeto especificado.Returns a value that indicates whether this instance is equal to a specified object.

(Herdado de Attribute)
GetHashCode()

Retorna o código hash para a instância.Returns the hash code for this instance.

(Herdado de Attribute)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
IsDefaultAttribute()

Quando substituído em uma classe derivada, indica se o valor dessa instância é o valor padrão para a classe derivada.When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Herdado de Attribute)
Match(Object)

Quando substituído em uma classe derivada, retorna um valor que indica se essa instância é igual a um objeto especificado.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Herdado de Attribute)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Implantações explícitas de interface

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de expedição.Maps a set of names to a corresponding set of dispatch identifiers.

(Herdado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera as informações de tipo para um objeto, que pode ser usado para obter as informações de tipo para uma interface.Retrieves the type information for an object, which can be used to get the type information for an interface.

(Herdado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Retorna o número de interfaces de informações do tipo que um objeto fornece (0 ou 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Herdado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornece acesso a propriedades e métodos expostos por um objeto.Provides access to properties and methods exposed by an object.

(Herdado de Attribute)

Aplica-se a

Confira também