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.
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.
| Exception | Condition |
|---|---|
| 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.
Available since 4.0