表达式树的深度限制 [英] Expression tree depth limitations

查看:118
本文介绍了表达式树的深度限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面对试图在类型表达式来的LambdaExpression调用编译()的一个问题; Func键< MyType的,布尔>>有大约400和较小值的深度不会引起任何问题。我不能找到这类限制的东西。任何人都可以澄清这一点? ?我可以增加此限制

I'm facing a problem trying to call Compile() on the LambdaExpression of type Expression<Func<MyType, bool>> which has a depth around 400. And lesser values do not cause any problems. And I can't find anything about such kind of limitation. Can anyone clarify this? Can I increase this limit?

UPD:
对不起,忘了提,我收到StackOverflowException:

upd: Sorry, forgot to mention, I'm getting StackOverflowException:

类型'System.StackOverflowException的未处理的异常出现在System.Core.dll
{因为当前线程堆栈溢出状态,无法计算表达式。}

推荐答案

您是否经过合法运行到堆栈大小的限制(虽然我质疑400多个项目拉姆达的智慧)。绕过最简单的方法是专门创建一个新的线程具有较大的堆栈执行本汇编,使用线程构造函数栈的大小作为参数:的 http://msdn.microsoft.com/en-us/library/ms149581.aspx

You are legitimately running into a limit on the stack size (although I question the wisdom of a 400+ item lambda). The easiest way to bypass that is to create a new thread specifically for performing this compilation with a larger stack, using the thread constructor that takes the stack size as an argument: http://msdn.microsoft.com/en-us/library/ms149581.aspx

呼叫编译在该线程,并增加堆栈大小参数是必要的。它以字节为单位,我相信,这将使约1048576默认的,所以从这里开始,并根据需要提出。

Call compile in that thread and increase the stack size argument as necessary. It is in bytes I believe, which would make the default about 1048576, so start there and raise it as needed.

这篇关于表达式树的深度限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆