P
Pete Davis
I've got the following code:
try
{
reader = new StreamReader(configFile);
XmlSerializer serializer = new XmlSerializer(typeof(ServerConfig));
config = (ServerConfig) serializer.Deserialize(reader);
}
catch(System.InvalidOperationException ioe)
{
Debug.WriteLine(ioe.ToString());
}
finally
{
reader.Close();
}
In this case, it throws an InvalidOperationException in the constructor for
the XmlSerializer(). I know why it's throwing the exception, and I can fix
it, but in the future, I'd like to catch it and handle it. Why can't I catch
it here?
The specific message is:
Unhandled Exception: System.InvalidOperationException: There is an error in
XML document (22, 4).
and it goes on a bit... Any ideas?
Pete
try
{
reader = new StreamReader(configFile);
XmlSerializer serializer = new XmlSerializer(typeof(ServerConfig));
config = (ServerConfig) serializer.Deserialize(reader);
}
catch(System.InvalidOperationException ioe)
{
Debug.WriteLine(ioe.ToString());
}
finally
{
reader.Close();
}
In this case, it throws an InvalidOperationException in the constructor for
the XmlSerializer(). I know why it's throwing the exception, and I can fix
it, but in the future, I'd like to catch it and handle it. Why can't I catch
it here?
The specific message is:
Unhandled Exception: System.InvalidOperationException: There is an error in
XML document (22, 4).
and it goes on a bit... Any ideas?
Pete