Short time before moving to Production with our application after upgrading it to .Net 2.0 - we have discover a major problem:
"Invalid Handle Exception" was thrown multiple times under Load Test.
It was thrown from SqlConnection.Open()
When looked in Reflector I saw the responsible for this exception was GetLastWin32Error method which is called somewhere in the call stack.
I have tried to understand why does it happen - and came to conclusion that this exception is originally thrown from other place in the system - and this GetLastWin32Error just catch it - Also it shouldn't:
"Multiple threads do not overwrite each
other's last-error code" (from MSDN)
So now I looked for the real source, I made a search on all our source code to find where we use Handles. Finally I have found a usage of System.Threading.WaitHandle.
I looked at MSDN and Voila, this WaitHandle.Handle is Obsolete...
just changed it to SafeWaitHandle and the problem disappeared!!!
Lesson Learned - Always remove Obsolete methods and classes.
They are obsolete for a reason...
No comments:
Post a Comment