I wrote a code in asp.net that read data from files and draw a graph.
It worked but after awhile when i run the program, this exception arise
"An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"
in this statement in the code:
if (File.Exists(fName)) <----(here is the exception)
{
stream = File.Open(fName, FileMode.Open);
g_day = Deserialize(stream);
stream.Close();
int cn = 0;
if (g_day.Values.Count != 0)
cn = g_day.Values[g_day.Values.Count - 1].Value;
Label1.Text = cn.ToString();
}
Your function is probably calling itself recursively an infinite number of times. Sometimes this happens indirectly (you call a method in the BCL and it calls back to your code, and this keeps repeating). File.Exists is probably not the culprit. Look at your call stack when the error occurs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With