S
Saurabh
Hi All,
I have an application which has certain preferences stored in a file. The
general architecture of reading these preferences is, There is a preferences
accessor class (Preferences) which has 2 static methods GetValue and
SetValue. My application accesses the preferences through this class using
the static method. The class has a static constructor where I read the file
and load the preferences into a hashtable. If the preferences file is not
found I throw an exception of type MyException derived from application
exception, which is caught by the first caller. so the calls are
//My application
try
{
string str = Preferences.GetValue("PreferredColor");
}
catch (MyApplicationException mae)
{
MessageBox.Show(mae.Message)
}
//Preferences class
public class Preferences
{
private static Hashtable _ht
static Preferences()
{
_ht = new Hashtable
LoadPreferences();
}
internal static LoadPreferences()
{
//code to read the file and load into the hashtable
if (File.Exist(<myfile>)
{
//read it
}
else
{
throw new MyApplicationException( );
}
}
public static GetValue(string key)
{
return _ht[key];
}
}
Now if the file is missing, I throw the exception but before reaching the
place where I catch the exception, the IDE exception handler kicks in and
shows the message and the control does not reach at all in my catch block.
Does anybody have a clue as to what is happening ?
--Saurabh
I have an application which has certain preferences stored in a file. The
general architecture of reading these preferences is, There is a preferences
accessor class (Preferences) which has 2 static methods GetValue and
SetValue. My application accesses the preferences through this class using
the static method. The class has a static constructor where I read the file
and load the preferences into a hashtable. If the preferences file is not
found I throw an exception of type MyException derived from application
exception, which is caught by the first caller. so the calls are
//My application
try
{
string str = Preferences.GetValue("PreferredColor");
}
catch (MyApplicationException mae)
{
MessageBox.Show(mae.Message)
}
//Preferences class
public class Preferences
{
private static Hashtable _ht
static Preferences()
{
_ht = new Hashtable
LoadPreferences();
}
internal static LoadPreferences()
{
//code to read the file and load into the hashtable
if (File.Exist(<myfile>)
{
//read it
}
else
{
throw new MyApplicationException( );
}
}
public static GetValue(string key)
{
return _ht[key];
}
}
Now if the file is missing, I throw the exception but before reaching the
place where I catch the exception, the IDE exception handler kicks in and
shows the message and the control does not reach at all in my catch block.
Does anybody have a clue as to what is happening ?
--Saurabh