AssemblyBuilder.Save Method (String, PortableExecutableKinds, ImageFileMachine)
Saves this dynamic assembly to disk, specifying the nature of code in the assembly's executables and the target platform.
Assembly: mscorlib (in mscorlib.dll)
public void Save( string assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine )
- Type: System.String
The file name of the assembly.
- Type: System.Reflection.PortableExecutableKinds
A bitwise combination of the PortableExecutableKinds values that specifies the nature of the code.
The length of assemblyFileName is 0.
There are two or more modules resource files in the assembly with the same name.
The target directory of the assembly is invalid.
assemblyFileName is not a simple file name (for example, has a directory or drive component), or more than one unmanaged resource, including a version information resources, was defined in this assembly.
assemblyFileName is null.
This assembly has been saved before.
This assembly has access Run AssemblyBuilderAccess
An output error occurs during the save.
CreateType has not been called for any of the types in the modules of the assembly to be written to disk.
If imageFileMachine and portableExecutableKind are incompatible, imageFileMachine takes precedence over portableExecutableKind. No exception is thrown. For example, if you specify ImageFileMachine.I386 with PortableExecutableKinds.PE32Plus, 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.
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 DefineDynamicAssembly methods that takes a target directory argument.