AppDomain.DefineDynamicAssembly Method (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean)
Defines a dynamic assembly using the specified name, access mode, storage directory, evidence, permission requests, and synchronization option.
Assembly: mscorlib (in mscorlib.dll)
[<ObsoleteAttribute("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>] abstract DefineDynamicAssembly : name:AssemblyName * access:AssemblyBuilderAccess * dir:string * evidence:Evidence * requiredPermissions:PermissionSet * optionalPermissions:PermissionSet * refusedPermissions:PermissionSet * isSynchronized:bool -> AssemblyBuilder [<ObsoleteAttribute("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>] override DefineDynamicAssembly : name:AssemblyName * access:AssemblyBuilderAccess * dir:string * evidence:Evidence * requiredPermissions:PermissionSet * optionalPermissions:PermissionSet * refusedPermissions:PermissionSet * isSynchronized:bool -> AssemblyBuilder
The unique identity of the dynamic assembly.
The mode in which the dynamic assembly will be accessed.
The name of the directory where the dynamic assembly will be saved. If dir is null, the directory defaults to the current directory.
The evidence supplied for the dynamic assembly. The evidence is used unaltered as the final set of evidence used for policy resolution.
The required permissions request.
The optional permissions request.
The refused permissions request.
true to synchronize the creation of modules, types, and members in the dynamic assembly; otherwise, false.
Return ValueType: System.Reflection.Emit.AssemblyBuilder
A dynamic assembly with the specified name and features.
The permission requests specified for requiredPermissions, optionalPermissions, and refusedPermissions are used only if evidence is also supplied, or if the dynamic assembly is saved and reloaded into memory.
During the development of code that emits dynamic assemblies, it is recommended that you include SecurityPermissionFlag.SkipVerification in refusedPermissions. Including SkipVerification in the refusedPermissions parameter ensures that the MSIL is verified. A limitation of this technique is that it also causes SecurityException to be thrown when used with code that demands full trust.
Only fully trusted callers can supply their evidence when defining a dynamic Assembly. The runtime will map the Evidence through the security policy to determine the granted permissions. Partially trusted callers must supply null for the evidence parameter. If evidence is null, the runtime copies the permission sets, that is, the current grant and deny sets, from the caller's Assembly to the dynamic Assembly being defined and marks policy as resolved.
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 completes.
For this code example to run, you must provide the fully qualified assembly name. For information about how to obtain the fully qualified assembly name, see Assembly Names.
Available since 1.1