相关疑难解决方法(0)

如何将表达式树保存为新的可执行磁盘文件的主要入口点?

我正在尝试将表达式树导出到PE程序集作为主要入口点.我通过构建表达式树获得了Lambda Expression,例如:

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.  ??? 
Run Code Online (Sandbox Code Playgroud)

第3步和第5步是我所缺少的.

delegates dynamic-assemblies

5
推荐指数
1
解决办法
1050
查看次数

标签 统计

delegates ×1

dynamic-assemblies ×1