Saves this dynamic assembly to disk, specifying the nature of code in the assembly's executables and the target platform.
- assemblyFileName
- The file name of the assembly.
- portableExecutableKind
- A bitwise combination of the System.Reflection.PortableExecutableKinds values that specifies the nature of the code.
- imageFileMachine
- One of the System.Reflection.ImageFileMachine values that specifies the target platform.
If imageFileMachine and portableExecutableKind are incompatible, imageFileMachine takes precedence over portableExecutableKind. No exception is thrown. For example, if you specify System.Reflection.ImageFileMachine.I386 with System.Reflection.PortableExecutableKinds.PE32Plus, System.Reflection.PortableExecutableKinds.PE32Plus is ignored.
This method saves all non-transient dynamic modules defined in this dynamic assembly. Transient dynamic modules are not saved. The assembly file name can be the same as the name of one of the module. If so, the assembly manifest is stored within that module. assemblyFileName can be different from the names of all of the modules contained within the assembly. If so, the assembly file contains only the assembly manifest.
For each System.Resources.ResourceWriter obtained using AssemblyBuilder.DefineResource(string, string, string), this method writes the .resources file and calls System.Resources.ResourceWriter.Close to close the stream.
The assemblyFileName needs to be a simple file name without a drive or directory component. To create an assembly in a specific directory, use one of the AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, AssemblyBuilderAccess) methods that takes a target directory argument.