Speichern eines Ausdrucksbaums als Haupteinstiegspunkt für eine neue ausführbare Festplattendatei

Ich versuche, einen Ausdrucksbaum als Haupteinstiegspunkt in eine PE-Assembly zu exportieren. Ich habe einen Lambda-Ausdruck durch Erstellen eines Ausdrucksbaums erhalten, zum Beispiel:

using System.Linq;
using System;

// 1. use expression trees to create a block expression (not shown)

// 2. create a lambda expression: 
LambdaExpression exprLambda = Expression.Lambda(exprBlock, new ParameterExpression[0]);

MethodBuilder mbuilder = null;
// 3. ??? Somehow get a method builder instance that works ??? 

// 4. Compile the lambda using the MethodBuilder instance. 
exprLambda.CompileToMethod(mbuilder);

// 5. ??? Somehow get an AssemblyBuilder instance to .Save(..) this to disk.  ??? 

Die Schritte 3 und 5 fehlen mir.

Antworten auf die Frage(1)

Ihre Antwort auf die Frage