【发布时间】:2018-02-04 00:05:19
【问题描述】:
当分配我的StreamReader 读取文件时,我有一个StackOverflowException,我不知道为什么会发生这种情况:(
这里是异常详情:
$exception {"Exception of type 'System.StackOverflowException' was thrown."} System.StackOverflowException
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
HResult -2147023895 int
HelpLink null string
+ InnerException null System.Exception
Message "Exception of type 'System.StackOverflowException' was thrown." string
Source null string
StackTrace null string
TargetSite null System.Reflection.MethodBase
+ Static members
+ Non-Public members
代码如下:
class Compile_Import
{
public static string getargs = null;
private static StreamReader sr;
public static void CompileAndRun(FileInfo importInfo, string args)
{
getargs = args;
if(importInfo.Extension == ".cbe" && importInfo.Exists)
{
sr = new StreamReader(importInfo.FullName); //Where my problem occurs.
string curlinecont = null;
while((curlinecont = sr.ReadLine()) != null)
{
string RawToken =
Parser.Parse.ParseLineIntoToken(Run.Stats.CurrentLineContents);
Token_Management.Process_Token.ActOnToken(RawToken);
}
}
}
【问题讨论】:
-
你能发布异常堆栈跟踪吗?
-
您要读取的文件有多大?
-
该文件实际上可能只有几行,大约 1kb 左右
-
你能发布 importInfo.FullName 属性代码吗?可能会进入某种递归?
-
我们需要查看
ParseLineIntoToken()和ActOnToken()方法。
标签: c# .net exception stack-overflow