Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

MethodBuilder.SetSymCustomAttribute Method

Set a symbolic custom attribute using a blob.

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

public void SetSymCustomAttribute(
	string name,
	byte[] data
)

Parameters

name
Type: System.String

The name of the symbolic custom attribute.

data
Type: System.Byte[]

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

ExceptionCondition
InvalidOperationException

The containing type was previously created using CreateType.

-or-

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

-or-

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.


	MethodBuilder myMethod = myDynamicType.DefineMethod("MyMethod",
						MethodAttributes.Public,
						typeof(int),
						new Type[] { typeof(string) });

	// A 128-bit key in hex form, represented as a byte array. 
	byte[] keyVal = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
			  0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xFF, 0xFF };	

	System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding();
	byte[] symFullName = encoder.GetBytes("My Dynamic Method");

	myMethod.SetSymCustomAttribute("SymID", keyVal);
	myMethod.SetSymCustomAttribute("SymFullName", symFullName);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft