ConstructorBuilder.SetSymCustomAttribute Method (String, Byte())


Sets this constructor's custom attribute associated with symbolic information.

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

Public Sub SetSymCustomAttribute (
	name As String,
	data As Byte()


Type: System.String

The name of the custom attribute.

Type: System.Byte()

The value of the custom attribute.

Exception Condition

The containing type has been created using CreateType.


The module does not have a symbol writer defined. For example, the module is not a debug module.

The following code sample illustrates the use of SetSymCustomAttributes.

Dim myMethodBuilder As MethodBuilder = Nothing
Dim myCurrentDomain As AppDomain = AppDomain.CurrentDomain
' Create assembly in current CurrentDomain.
Dim myAssemblyName As New AssemblyName()
myAssemblyName.Name = "TempAssembly"
' Create a dynamic assembly.
myAssemblyBuilder = myCurrentDomain.DefineDynamicAssembly(myAssemblyName, _
' Create a dynamic module in the assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule", True)
Dim myFieldInfo As FieldInfo = myModuleBuilder.DefineUninitializedData("myField", 2, _
' Create a type in the module.
Dim myTypeBuilder As TypeBuilder = myModuleBuilder.DefineType("TempClass", TypeAttributes.Public)
Dim myGreetingField As FieldBuilder = myTypeBuilder.DefineField("Greeting", GetType(String), _
Dim myConstructorArgs() As Type = { GetType(String) }
' Define a constructor of the dynamic class.
Dim myConstructor As ConstructorBuilder = _
          myTypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, _
' Display the name of the constructor.
Console.WriteLine("The constructor name is  : " + myConstructor.Name)
myConstructor.SetSymCustomAttribute("MySimAttribute", New Byte() {01, 00,00})

.NET Framework
Available since 1.1
Return to top