我编写了一个程序,用于监控连接到串行端口的设备。 当我直接使用编译的发行版本时,一切正常。我使用Installshield LE为此工具创建了一个安装程序,在安装的版本中,我的代码的某些部分无法正常工作或似乎缺失。
例如:
string[] getSerialData(string command, int expectedlength)
{
string[] Ausgabe = { "" };
while (Ausgabe.Length != expectedlength && run)
{
if (IPS_Port.IsOpen)
IPS_Port.Write(command);
try
{
Ausgabe = IPS_Port.ReadTo("\t").ToString().Split(splitString, StringSplitOptions.RemoveEmptyEntries);
}
catch (TimeoutException)
{
j++;
if (j >= 8)
{
notico.ShowBalloonTip(30000,"Error","You lost connection to your IPS \"" + IPSname + "\"!",ToolTipIcon.Error);
logWriter = new StreamWriter("ErrorLog.log",true);
logWriter.WriteLine(DateTime.Now.ToString("dd/MM/yyyy - HH:mm:ss tt") + "(" + IPSname + "): Connection Lost!");
logWriter.Close();
lostConnection = true;
reset();
break;
}
continue;
}
}
j = 0;
return Ausgabe;
}
它一直持续到notico.ShowBallonTip
并卡在那里(一遍又一遍地显示气球提示),但从未到达logwriter部分,也没有到达reset()
命令。
为什么会发生这种情况,我该如何解决?