Kompilatorfel C3104

ogiltigt attributargument

Anmärkningar

Du har angett ett ogiltigt argument för ett attribut.

Mer information finns i Attributparametertyper .

Det här felet kan genereras som ett resultat av kompilatorns överensstämmelsearbete som utfördes för Visual Studio 2005: när hanterade matriser skickas till anpassade attribut härleds inte längre typen av matrisen från den aggregerade initieringslistan. Kompilatorn kräver nu att du anger typen av matris samt initialiserarlistan.

Examples

I följande exempel genereras C3104.

// C3104a.cpp
// compile with: /clr /c
using namespace System;

[AttributeUsage(AttributeTargets::Class)]
public ref struct ABC : public Attribute {
   ABC(array<int>^){}
   array<double> ^ param;
};

[ABC( {1,2,3}, param = {2.71, 3.14})]   // C3104
// try the following line instead
// [ABC( gcnew array<int> {1,2,3}, param = gcnew array<double>{2.71, 3.14})]
ref struct AStruct{};

I följande exempel genereras C3104.

// C3104b.cpp
// compile with: /clr /c
// C3104 expected
using namespace System;

int func() {
   return 0;
}

[attribute(All)]
ref class A {
public:
   A(int) {}
};

// Delete the following 2 lines to resolve.
[A(func())]
ref class B {};

// OK
[A(0)]
ref class B {};