0

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

3
  • can you post some code and/or be more explicit please ? Commented Jul 29, 2011 at 17:47
  • When you look at the error in the debugger - what sort of Exception is being reported? If it's only throwing a generic Exception (rather than more specific XMLException etc) then you're out of luck. On the other hand a re-factor could trap the error when it happens (leaving other errors able to bubble out) or even drop whatever the assumption is that's causing the error. Commented Jul 29, 2011 at 17:49
  • when i look to the debugger this what i can see "There is an error in XML document(19,10)" Commented Jul 29, 2011 at 17:54

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.