我有这样的代码从我得到的异常中向我展示StackTrace:
catch (Exception x)
{
MessageBox.Show(string.Format("Booboo ({0}) in buttonGetDeviceLangVal_Click(). StackTrace == {1}",
x.Message, x.StackTrace));
}
...但由于房地产的限制,我无法从微不足道的混乱装置(手持设备)的内部看到整个公报;我无法将MessageBox拖得更高 - 它将头撞到顶部并拒绝在屋顶上打个洞,以便我可以看到故事的其余部分。
那么我怎样才能让MessageBox将字符串分成可以循环播放的“剧集”?
我的想法(伪代码)是这样的:
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;
}
}
...但我觉得有人“在那里”有更好的主意或者已经解决了这个问题......我认为是吗?
答案 0 :(得分:0)
这有效:
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;
}
}
不幸的是,由此产生的双重情节MessageBox显示对underlying problem没什么帮助。它只是告诉我(简而言之):
Control-OnClick
Button-Onclick
ButtonBase-WinProc
Forms.Ctrl_InternalWinProc
Microsoft.AGL.Forms.EVL_EnterMainLoop
ApplicationRun