Export (0) Print
Expand All

AppDomain.DefineDynamicAssembly Method (AssemblyName, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>, SecurityContextSource)

Defines a dynamic assembly with the specified name, access mode, and custom attributes, and using the specified source for its security context.

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

public AssemblyBuilder DefineDynamicAssembly(
	AssemblyName name,
	AssemblyBuilderAccess access,
	IEnumerable<CustomAttributeBuilder> assemblyAttributes,
	SecurityContextSource securityContextSource
)

Parameters

name
Type: System.Reflection.AssemblyName

The unique identity of the dynamic assembly.

access
Type: System.Reflection.Emit.AssemblyBuilderAccess

The access mode for the dynamic assembly.

assemblyAttributes
Type: System.Collections.Generic.IEnumerable<CustomAttributeBuilder>

An enumerable list of attributes to be applied to the assembly, or null if there are no attributes.

securityContextSource
Type: System.Security.SecurityContextSource

The source of the security context.

Return Value

Type: System.Reflection.Emit.AssemblyBuilder
A dynamic assembly with the specified name and features.

ExceptionCondition
ArgumentNullException

name is null.

ArgumentException

The Name property of name is null.

-or-

The Name property of name starts with white space, or contains a forward or backward slash.

AppDomainUnloadedException

The operation is attempted on an unloaded application domain.

ArgumentOutOfRangeException

The value of securityContextSource was not one of the enumeration values.

Use this method overload to specify attributes that do not work correctly unless they are applied when a dynamic assembly is created. For example, security attributes such as SecurityTransparentAttribute and SecurityCriticalAttribute do not work correctly if they are added after a dynamic assembly has been created.

This method should be used only to define a dynamic assembly in the current application domain. For more information about this restriction, see the Load(AssemblyName) method overload.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft