Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,
could you post some code?
Also take a look in the deail of the exception , as the line # of
where the error occurred.
I inserted a test line to make sure this is where the problem was and
it is. The following is in the Main() method:
Main.GetINISettings();
try
{
string vstr = SharedClass.Params["LOGSERVER"].ToString();
}
catch (Exception E1)
{
MessageBox.Show("Main Params: " + E1.Message);
throw (new Exception(E1.Message));
}
And here is the GetINISettings method:
private void GetINISettings()
{
if (System.IO.File.Exists(IniName))
{
FileStream vini = new FileStream(IniName, FileMode.Open);
StreamReader vsr = new StreamReader(vini);
String[] elements;
try
{
while (!vsr.EndOfStream)
{
string vstr = vsr.ReadLine();
elements = vstr.Split('=');
SharedClass.Params.Add(elements[0], elements[1]);
}
}
catch (Exception Ex)
{
vsr.Close();
vini.Close();
Environment.ExitCode = 9000;
throw (new Exception("Config file not found or invalid: " +
Ex.Message));
//MessageBox.Show("Config file not found or invalid. " +
Ex.Message, "Error", MessageBoxButtons.OK);
return;
};
if (vsr != null)
vsr.Close();
if (vini != null)
vini.Close();
}
}
--
Don Gollahon