A very useful method when used with caution. Yes with caution!
Recently I was asked by our BA to use the IsNullOrEmpty method while checking for the existence of value in a string variable. Its new to me. He said that it has more performance than the usual way of doing this.
I decided to dig more about this. In the next 15 minutes i found that it has its own issues.
Yes issue, a very big one !
When used inside a loop it will crash the whole application. No error handling works here.
This is caused by JIT optimization.
Bill has a good write up about this here: http://msmvps.com/blogs/bill/archive/2006/04/04/89234.aspx
Note this happens only when you build your application in release mode with optimizations on.
Microsoft has the following page on the issue. Fix is available only in Orcas.
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=113102
Well, as for me I am now fixing those IsNullOrEmpty method calls along with the rest of the team .....
One more issue to fix ................................................... ;-)
About Me
- Saran
Categories
- .NET (2)
- assembly not copied (1)
- Asynchronous logging (1)
- Asynchronous logging application block (1)
- Enterprise library (1)
- exception handling application block (1)
- logging application block (1)
- Silverlight tree (1)
- Sql Server 2005 (1)
- SSIS (1)
- SSIS configuration file warning (1)
- SSIS packages (1)
- Visual Studio 2008 Install-fest (1)
- VS 2008 Installfest (1)
Blog Archive
Monday, September 10, 2007
Beware of String.IsNullOrEmpty
Posted by Saran at 9:09 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment