Nota
O acesso a esta página requer autorização. Pode tentar iniciar sessão ou alterar os diretórios.
O acesso a esta página requer autorização. Pode tentar alterar os diretórios.
«tipo»: não é um atributo; não é possível especificar [System::AttributeUsageAttribute] ou [Windows::Foundation::Metadata::AttributeUsageAttribute]
Observações
Um atributo gerenciado definido pelo usuário deve herdar do AttributeCollection. Um atributo do Tempo de Execução do Windows deve ser definido no Windows::Foundation::Metadata namespace.
Para obter mais informações, consulte Atributos Definido pelo Usuário.
Example
O exemplo a seguir gera C3450 e mostra como corrigi-lo.
// C3450.cpp
// compile with: /clr
// C3450 expected
using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
public ref class MyClass {};
class MyClass2 {};
[attribute(AttributeTargets::All)]
ref struct AtClass {
AtClass(Type ^) {}
};
[attribute(AttributeTargets::All)]
ref struct AtClass2 {
AtClass2() {}
};
// Apply the AtClass and AtClass2 attributes to class B
[AtClass(MyClass::typeid), AtClass2]
[AttributeUsage(AttributeTargets::All)]
// Delete the following line to resolve.
ref class B {};
// Uncomment the following line to resolve.
// ref class B : Attribute {};