开发者

LambdaExpression CompileToMethod

开发者 https://www.devze.com 2023-01-21 01:35 出处:网络
I Have a few lines of code public void CreateMethod<TContract>(Expression<Action<TContract>> method)

I Have a few lines of code

public void CreateMethod<TContract>(Expression<Action<TContract>> method)
{
   var innerMethod = Builder.DefineMethod("SomeName",MethodAttributes.Private);
   method.CompileToMethod(innerMethod);
   //more code
}

However the second line fails. I've tried with different versions o开发者_如何学Cf DefineMethod with little luck. Any suggestions?


Unfortunately, CompileToMethod requires a static method as its argument (see here). Therefore, you need to add MethodAttributes.Static to innerMethod's definition.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号