Exception while dynamically creating assemblies using DefineDynamicAssembly on non-current AppDomain
问题 I want to dynamically create assemblies in the integration tests for the purpose of testing some assembly manipulation classes. If I use the following code to create the testing assemblies: var domain = AppDomain.CurrentDomain; var builder = domain.DefineDynamicAssembly( new AssemblyName(assemblyName), AssemblyBuilderAccess.Save, directory); builder.Save(fileName); then everything runs ok, the assemblies are created in the required location, but as part of this they are also loaded to the