Hi Eric,
I agree with Chris that it is likely that your event handler triggered some
other code which recursively called this event handler again, so an
infinitely calling chain is generated, which causes
StatckOverflowException.
The simplest way to find out the root cause is catching this
StatckOverflowException with a debugger and examine the call stack of this
exception, which will reveal the deep stack root cause clearly.
Normally, when you run your application without debugging, the
StatckOverflowException is thrown, the system will popup a dialog for you
to choose a debugger. You may use a VS2005 instance with source code to
debug this exception. After using the debugger to attach the failure
application, you may open "Call Stack" window from "Debug" menu. Once you
have got the symbol setup correctly, you will get a meaningful call stack
for this StatckOverflowException .
For example, in my test winform application, I used the code snippet below
to simulate the StatckOverflowException:
void RecursionMethod()
{
Console.WriteLine("RecursionMethod");
RecursionMethod();
}
private void button1_Click(object sender, System.EventArgs e)
{
RecursionMethod();
}
When the StatckOverflowException is generated, I choose my source code
debugger in the popup dialog. After the debugger breaks into the
application, I will get the following call stack:
mscorlib.dll!System.IO.TextWriter.WriteLine(string value) Line 448 + 0x3a
bytes C#
mscorlib.dll!SyncTextWriter.WriteLine(string value) Line 711 + 0x1b bytes
C#
mscorlib.dll!System.Console.WriteLine(string value) Line 408 + 0x1e bytes
C#
> StackOverflowTest.exe!StackOverflowTest.Form1.Recu rsionMethod() Line 103
C#
StackOverflowTest.exe!StackOverflowTest.Form1.Recu rsionMethod() Line 104
C#
StackOverflowTest.exe!StackOverflowTest.Form1.Recu rsionMethod() Line 104
C#
StackOverflowTest.exe!StackOverflowTest.Form1.Recu rsionMethod() Line 104
C#
.................................................. ....................
StackOverflowTest.exe!StackOverflowTest.Form1.Recu rsionMethod() Line 104 C#
It is very clear that the root cause of the StatckOverflowException is
generated by recursively calling RecursionMethod.
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.