C# 无法计算表达式错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18378170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 12:04:55  来源:igfitidea点击:

Cannot evaluate expression error

c#

提问by vysakh

While debugging my application, I am getting the error as "Cannot evaluate expression because the current thread is in a stack overflow state.". I have googled for this error but could not find the code, where the error happens. But in my case, it is not showing where the error is stuck.

在调试我的应用程序时,我收到错误消息“无法计算表达式,因为当前线程处于堆栈溢出状态。”。我用谷歌搜索了这个错误,但找不到发生错误的代码。但就我而言,它没有显示错误卡在哪里。

And it shows a picture like this:

它显示了这样的图片:

enter image description here

在此处输入图片说明

Can anyone please suggest any further step I can take to drill down the source of this overflow. I have completed coding part in my application..But unfortunately can not debug. Any ideas would be really appreciated...

任何人都可以建议我可以采取任何进一步的步骤来深入了解此溢出的来源。我已经在我的应用程序中完成了编码部分..但不幸的是无法调试。任何想法将不胜感激...

Just now I am noticing that I have some files(.cs) which has only code, but no design. Will that result in such a stackoverflow exception?

刚才我注意到我有一些只有代码但没有设计的文件(.cs)。这会导致这样的stackoverflow异常吗?

采纳答案by vysakh

It was not anything with recursive functions or if conditions..I was calling multiple objects at the same time in my application, which resulted in StackOverflowException..I made some modifications in my program.Now it works fine..Thanks guys for all your support...

它与递归函数或 if 条件无关......我在我的应用程序中同时调用多个对象,这导致 StackOverflowException..我在我的程序中做了一些修改。现在它工作正常......谢谢你们所有的人支持...

回答by Dan Puzey

A StackOverflowExceptionis an unrecoverable error. You can't evaluate anything at that point, but the call-stack of your current thread will probably clearly indicate the cause.

AStackOverflowException是不可恢复的错误。此时您无法评估任何内容,但当前线程的调用堆栈可能会清楚地指出原因。

Examine the call-stack and modify your code appropriately - most likely, you have an infinite recursion (or you have self-referential markup/xml/similar that is causing a .NET library to infinitely recurse).

检查调用堆栈并适当地修改您的代码 - 最有可能的是,您有一个无限递归(或者您有导致 .NET 库无限递归的自引用标记/xml/similar)。

回答by Rik

I'm guessing you have something like this in your code:

我猜你的代码中有这样的东西:

private T field;

public T Field
{
    get
    { 
         return Field; // note the capital F, causing recursion and eventually a StackOverflowExcpetion
    }
}