AppDomain.DefineDynamicAssembly Method (AssemblyName, AssemblyBuilderAccess, Evidence, PermissionSet, PermissionSet, PermissionSet)
Defines a dynamic assembly using the specified name, access mode, evidence, and permission requests.
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 * evidence:Evidence * requiredPermissions:PermissionSet * optionalPermissions:PermissionSet * refusedPermissions:PermissionSet -> 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 * evidence:Evidence * requiredPermissions:PermissionSet * optionalPermissions:PermissionSet * refusedPermissions:PermissionSet -> AssemblyBuilder
The unique identity of the dynamic assembly.
The mode in which the dynamic assembly will be accessed.
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.
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 a null evidence. 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.
This method should only be used to define a dynamic assembly in the current application domain. For more information, see the Load(AssemblyName) method overload.
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