I wrote a C# tool which is running as a standard console application. At the end of the program I used Console.Read()
to prevent the window to close. This works fine for all my colleagues PC except one. He never saw my application. It did all the work to do but it closes afterwards. All PC run WinXP. Do you have any idea?
I implemented a try-catch-finally where the finally includes nothing but Console.Read()
.
EDIT: I added some code
Console.SetWindowSize(125, 40);
CopyToolBase ctb = null;
try
{
DateTime startTime = DateTime.Now;
TimeSpan duration;
ctb = CopyToolBase.GetInstance(Defines.configPath);
if (null == ctb)
{
throw new KopiertoolException();
}
if (null == ctb.GetNewestVersion())
{
throw new KopiertoolException();
}
if (!ctb.CheckCopy())
{
throw new KopiertoolException();
}
if (!ctb.CopyAndUnzip())
{
throw new KopiertoolException();
}
duration = DateTime.Now.Subtract(startTime);
ctb.PrintSuccess("xxxxxxxx");
ctb.PrintInfo("Gesamtdauer: " + ((duration.Hours == 0) ? "" : string.Format("{0:00} Std ", duration.Hours)) + string.Format("{0:00} Min {1:00} Sek", duration.Minutes, duration.Seconds));
startTime = DateTime.Now;
if (!ctb.StartTask())
{
throw new KopiertoolException();
}
duration = DateTime.Now.Subtract(startTime);
if (duration.Minutes > 1)
{
ctb.PrintInfo("Dauer: " + ((duration.Hours == 0) ? "" : string.Format("{0:00} Std ", duration.Hours)) + string.Format("{0:00} Min {1:00} Sek", duration.Minutes, duration.Seconds));
}
}
catch (KopiertoolException)
{
ctb.WriteToLog();
}
catch (Exception ex)
{
if (ctb == null)
{
Console.WriteLine("xxxxxxxxx");
Console.WriteLine(ex.ToString());
}
else
{
ctb.PrintError("xxxxxxxxx");
ctb.PrintError(ex.ToString());
ctb.WriteToLog();
}
}
finally
{
Console.Read();
}