I have code like this to show me the StackTrace from an exception I'm getting:
catch (Exception x)
{
MessageBox.Show(string.Format("Booboo ({0}) in buttonGetDeviceLangVal_Click(). StackTrace == {1}",
x.Message, x.StackTrace));
}
...but I cannot see the entire communique from the bowels of the puny confounded contraption (handheld device) due to the real estate constraints; I cannot drag the MessageBox higher - it bumps its head against the top and refuses to make a hole in the roof so that I can see the rest of the story.
So how can I get the MessageBox to split the string into "episodes" that I can cycle through?
My idea (pseudocode) is something like this:
catch (Exception x)
{
const int MAX_CHARS_TO_SHOW = 314;
string exmsg = string.Format("Booboo ({0}) in
buttonGetDeviceLangVal_Click(). StackTrace == {1}",
x.Message, x.StackTrace);
int msglen = exmsg.Len;
int charsDisplayed = 0;
while (charsDisplayed < msglen) do
{
string exmsgepisode = String.Copy(exmsg, charsDisplayed, MAX_CHARS_TO_SHOW);
MessageBox.Show(exmsgepisode);
charsDisplayed += charsDisplayed;
}
}
...but I reckon somebody "out there" has a better idea or has already solved this...did I reckon right?
This works:
catch (Exception x)
{
const int MAX_CHARS_TO_SHOW = 314;
string exmsg = string.Format("Boo-boo in buttonGetDeviceLangVal_Click(): == {0}", x);
int msglen = exmsg.Length;
int charsDisplayed = 0;
while (charsDisplayed < msglen)
{
int CharsToGrab = MAX_CHARS_TO_SHOW;
int CharsLeft = msglen - charsDisplayed;
if (CharsLeft < MAX_CHARS_TO_SHOW) CharsToGrab = CharsLeft;
string msgepisode = exmsg.Substring(charsDisplayed, CharsToGrab);
int episodeLen = msgepisode.Length;
MessageBox.Show(msgepisode);
charsDisplayed = charsDisplayed + episodeLen;
}
}
Unfortunately, the resulting dual episodic MessageBox showing didn't help me much with the underlying problem. It just tells me (in a nutshell):
Control-OnClick
Button-Onclick
ButtonBase-WinProc
Forms.Ctrl_InternalWinProc
Microsoft.AGL.Forms.EVL_EnterMainLoop
ApplicationRun