This documentation is archived and is not being maintained.

ConstructorBuilder.SetSymCustomAttribute Method

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

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

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

Parameters

name

The name of the custom attribute.

data

The value of the custom attribute.

Exception typeCondition

InvalidOperationException

The containing type has been created using CreateType.

-or-

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.

MethodBuilder myMethodBuilder = null;
AppDomain myCurrentDomain = AppDomain.CurrentDomain;
// Create assembly in current CurrentDomain.
AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = "TempAssembly";
// Create a dynamic assembly.
myAssemblyBuilder = myCurrentDomain.DefineDynamicAssembly
         (myAssemblyName, AssemblyBuilderAccess.Run);
// Create a dynamic module in the assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule",true);
FieldInfo myFieldInfo =
   myModuleBuilder.DefineUninitializedData("myField", 2, FieldAttributes.Public);
// Create a type in the module.
TypeBuilder myTypeBuilder = myModuleBuilder.DefineType("TempClass",TypeAttributes.Public);
FieldBuilder myGreetingField = myTypeBuilder.DefineField("Greeting", 
                                    typeof(String), FieldAttributes.Public);
Type[] myConstructorArgs = { typeof(String) };
// Define a constructor of the dynamic class.
ConstructorBuilder myConstructor = myTypeBuilder.DefineConstructor(
MethodAttributes.Public, CallingConventions.Standard, myConstructorArgs);
// Display the name of the constructor.
Console.WriteLine("The constructor name is  : "+ myConstructor.Name);
myConstructor.SetSymCustomAttribute("MySimAttribute", new byte[]{01,00,00});

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: