How to use "try-catch" to handle InvalidCastException in vb.net?
Posted on 2013-02-02
Our app is failing intermittently at the customer site with an InvalidCastException. There are reasons why it is very difficult to determine exactly why it is happening, and in which line of code, but the error text does show me which sub it failed in.
That sub has several if-then sections, and I feel sure the runtime problem is occuring in one of those sections. So here is my question: Can I simply put a Try statement at the top of the sub, and the Catch statement at the bottom of the sub, and expect it to handle whatever is going wrong--without erroring out of the program? Is it that simple, or are there other considerations in a situation like this?