Is it possible for a .Net Framework 4.6.2 project to use System.Reflection.Emit to create a .Net Core or .Net Standard DLL file? What I have now is a project that generates a .Net Framework 4.0 DLL file. Can I change some setting somewhere so that the generated DLL file uses .Net Core or .Net Standard instead?
Edit: Here's an example. I got the following code from this page that covers the System.Reflection.Emit library.
static void Main(string[] args)
{
AppDomain ad = AppDomain.CurrentDomain;
AssemblyName am = new AssemblyName();
am.Name = "TestAsm";
AssemblyBuilder ab = ad.DefineDynamicAssembly(am, AssemblyBuilderAccess.Save);
ModuleBuilder mb = ab.DefineDynamicModule("testmod", "TestAsm.exe");
TypeBuilder tb = mb.DefineType("mytype", TypeAttributes.Public);
MethodBuilder metb = tb.DefineMethod("hi", MethodAttributes.Public |
MethodAttributes.Static, null, null);
ab.SetEntryPoint(metb);
ILGenerator il = metb.GetILGenerator();
il.EmitWriteLine("Hello World");
il.Emit(OpCodes.Ret);
tb.CreateType();
ab.Save("TestAsm.exe");
}
When I run this code, it generates TestAsm.exe. When I open TestAsm.exe in my decompiler (JetBrains dotPeek), it shows that TestAsm.exe is "msil, .Net Framework v4.0, Debug"
How do I change this? My project is a .Net 4.6.2 project, so the generated EXE is not based on the generating project's framework version.