问题
How to port the following code to .Net Core:
AppDomain.CurrentDomain.DefineDynamicAssembly(
new AssemblyName(
Guid.NewGuid().ToString()),
AssemblyBuilderAccess.RunAndSave);
Is it possible?
回答1:
add this to your project.json
"dependencies": {
"System.Reflection.Emit": "4.0.1"
},
and use
AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(Guid.NewGuid().ToString()),
AssemblyBuilderAccess.Run);
AssemblyBuilderAccess.RunAndSave
is not supported at the moment link to souce.
Update:
For new .csproj
projects use:
<ItemGroup>
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
</ItemGroup>
来源:https://stackoverflow.com/questions/36937276/is-there-any-replace-of-assemblybuilder-definedynamicassembly-in-net-core