Reputation: 737
I have a program that will read scripts, if i open new scripts with an older version of this software will catch an error: "There is an error in XML document(19,10)" and this cause i catch err as Exception. i want to keep this catch but i want to create another catch before this to catch this kind of error, when XML parse fail, I tried to use XMLException type but it will never catch the error and keep going to the general exception catch. any idea how to get the xml parse catch.
thank you
Upvotes: 0
Views: 289
Reputation: 62544
Such a message appears whilst deserialization and its type as far as I remember is InvalidOperationException
.
So just add an other one catch(InvalidOperationException exception)
block and see whether it works for you.
BTW, real exception with more specific details should be in the InnerException property of an actual exception.
Upvotes: 1