Exception -al issues in .NET
Quite often I have seen "Object reference not set" error in .net applications. The error is not a developer intended error its just the basic understanding of exceptions not being clear. Whenever an exception is thrown deep in the code the developer intends to highlight this exception and hence re-throws the exception. In .net when you re-throw an exception it creates a new exception on the stack and hence this is the "Object reference not set" a very misleading error.Therefore instead of doing this
throw new exception("Message")
do only this
throw
Hence the right exception info is obtained when the exception is handled at the interface level. Most large projects should develop their own exception handling mechanism and not depend on this.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home