MethodBuilder::SetSymCustomAttribute Method (String^, array<Byte>^)


Set a symbolic custom attribute using a blob.

Namespace:   System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

void SetSymCustomAttribute(
	String^ name,
	array<unsigned char>^ data


Type: System::String^

The name of the symbolic custom attribute.

Type: array<System::Byte>^

The byte blob that represents the value of the symbolic custom attribute.

Exception Condition

The containing type was previously created using CreateType.


The module that contains this method is not a debug module.


For the current method, the IsGenericMethod property is true, but the IsGenericMethodDefinition property is false.

Unlike the metadata custom attribute, this custom attribute is associated with a symbol writer.

The code sample below illustrates the contextual usage of the SetSymCustomAttribute method to set the byte values for the name and key of a custom attribute attached to a method.

array<Type^>^ temp0 = { String::typeid };
MethodBuilder^ myMethod = myDynamicType->DefineMethod( "MyMethod",
                          temp0 );

// A 128-bit key in hex form, represented as a Byte array.
array<Byte>^ keyVal = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xFF, 0xFF};

System::Text::ASCIIEncoding^ encoder = gcnew System::Text::ASCIIEncoding;
array<Byte>^ symFullName = encoder->GetBytes( "My Dynamic Method" );

myMethod->SetSymCustomAttribute( "SymID", keyVal );
myMethod->SetSymCustomAttribute( "SymFullName", symFullName );

.NET Framework
Available since 1.1
Return to top