Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DefineDynamicAssembly Method (AssemblyName, AssemblyBuilderAccess, String, Boolean, IEnumerable(CustomAttributeBuilder))
Collapse the table of content
Expand the table of content

AppDomain.DefineDynamicAssembly Method (AssemblyName, AssemblyBuilderAccess, String, Boolean, IEnumerable(Of CustomAttributeBuilder))

Defines a dynamic assembly using the specified name, access mode, storage directory, and synchronization option.

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

'Declaration
Public Function DefineDynamicAssembly ( _
	name As AssemblyName, _
	access As AssemblyBuilderAccess, _
	dir As String, _
	isSynchronized As Boolean, _
	assemblyAttributes As IEnumerable(Of CustomAttributeBuilder) _
) As AssemblyBuilder

Parameters

name
Type: System.Reflection.AssemblyName
The unique identity of the dynamic assembly.
access
Type: System.Reflection.Emit.AssemblyBuilderAccess
The mode in which the dynamic assembly will be accessed.
dir
Type: System.String
The name of the directory where the dynamic assembly will be saved. If dir is Nothing, the current directory is used.
isSynchronized
Type: System.Boolean
true to synchronize the creation of modules, types, and members in the dynamic assembly; otherwise, false.
assemblyAttributes
Type: System.Collections.Generic.IEnumerable(Of CustomAttributeBuilder)
An enumerable list of attributes to be applied to the assembly, or Nothing if there are no attributes.

Return Value

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

ExceptionCondition
ArgumentNullException

name is Nothing.

ArgumentException

The Name property of name is Nothing.

-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.

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.

If isSynchronized is true, the following methods of the resulting AssemblyBuilder will be synchronized: DefineDynamicModule, DefineResource, AddResourceFile, GetDynamicModule, SetEntryPoint, and Save. If two of these methods are called on different threads, one will block until the other is completed.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2015 Microsoft