<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx</link><description>UPDATE: This bug was fixed in .NET 2.0 SP1 940900 (http://support.microsoft.com/kb/940900/ ) FIX: You receive the NullReferenceException exception when you call the String.IsNullOrEmpty function in an application that is built on the .NET Framework 2</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>String.IsNullOrEmpty - performance considerations, bugs</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#1654677</link><pubDate>Thu, 20 Nov 2008 16:07:34 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1654677</guid><dc:creator>Technical Musings</dc:creator><description>&lt;p&gt;I once read that .Net&amp;#39;s String.IsNullOrEmpty performs better, and is safer, than just checking to see if a particular string has an empty value. I.e. replace if (myString == &amp;quot;&amp;quot;) or if (myString.Equals(string.Empty)) or if (myString.Length == 0) with if&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1654677" width="1" height="1"&gt;</description></item><item><title>Controlling the usage of libraries</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#1651419</link><pubDate>Mon, 20 Oct 2008 18:26:32 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1651419</guid><dc:creator>Community Blogs</dc:creator><description>&lt;p&gt;Recently, Scott Hanselman has proposed a survey to know which part of the .NET Framework real-world developers&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1651419" width="1" height="1"&gt;</description></item><item><title>Controlling the usage of libraries</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#1651414</link><pubDate>Mon, 20 Oct 2008 17:48:01 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1651414</guid><dc:creator>Patrick Smacchia [MVP C#]</dc:creator><description>&lt;p&gt;Recently, Scott Hanselman has proposed a survey to know which part of the .NET real-world developers&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1651414" width="1" height="1"&gt;</description></item><item><title>El bug de String.IsNullOrEmpty en .NET 2.0</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#1073614</link><pubDate>Mon, 30 Jul 2007 19:11:31 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1073614</guid><dc:creator>vtortola</dc:creator><description>&lt;p&gt;Leo en un blog de MSMVPs.com una noticia de hace m&amp;#225;s de un a&amp;#241;o que contaba que se detecto un bug en el&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1073614" width="1" height="1"&gt;</description></item><item><title>Bug en String.IsNullOrEmpty en .NET 2.0</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#1071292</link><pubDate>Sun, 29 Jul 2007 23:58:06 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1071292</guid><dc:creator>vtortola</dc:creator><description>&lt;p&gt;Leo en un blog de MSMVPs.com que se ha detectado un bug en el m&amp;#233;todo est&amp;#225;tico String.IsNullOrEmpty causado&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1071292" width="1" height="1"&gt;</description></item><item><title>dangerous behaviour of String.IsNullOrEmpty at  www2.sitina.net</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#983791</link><pubDate>Sun, 24 Jun 2007 05:25:23 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:983791</guid><dc:creator>dangerous behaviour of String.IsNullOrEmpty at  www2.sitina.net</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;dangerous behaviour of String.IsNullOrEmpty at &amp;nbsp;www2.sitina.net&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=983791" width="1" height="1"&gt;</description></item><item><title>Okay this is nice, trust me | Suddenelfilio 's Blog</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#975207</link><pubDate>Wed, 20 Jun 2007 07:45:37 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:975207</guid><dc:creator>Okay this is nice, trust me | Suddenelfilio 's Blog</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Okay this is nice, trust me | Suddenelfilio 's Blog&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=975207" width="1" height="1"&gt;</description></item><item><title>String.IsNulOrEmpty Flaw</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#971697</link><pubDate>Mon, 18 Jun 2007 16:12:32 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:971697</guid><dc:creator>Dityo Nurasto Journal</dc:creator><description>&lt;p&gt;String.IsNulOrEmpty Flaw&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=971697" width="1" height="1"&gt;</description></item><item><title>String.IsNullOrEmpty can lead to runtime Null exceptions!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#968594</link><pubDate>Sun, 17 Jun 2007 14:23:39 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:968594</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You've been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=968594" width="1" height="1"&gt;</description></item><item><title>Thomas goes .NET - String.IsNullOrEmpty() schmei??t Exceptions</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#132919</link><pubDate>Tue, 19 Sep 2006 13:34:47 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:132919</guid><dc:creator>Thomas goes .NET - String.IsNullOrEmpty() schmei??t Exceptions</dc:creator><description>PingBack from http://blog.thomasbandt.de/PermaLink,guid,d6de00ed-ab10-485a-bda4-615e53eb3981.aspx&lt;img src="http://msmvps.com/aggbug.aspx?PostID=132919" width="1" height="1"&gt;</description></item><item><title>Be careful with String.IsNullOrEmpty</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#132200</link><pubDate>Tue, 19 Sep 2006 09:07:45 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:132200</guid><dc:creator>Jean-Paul Smit</dc:creator><description>&lt;p&gt;While I ran FxCop over someone else's code it pointed me to a String method I didn't know about: IsNullOrEmpty&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=132200" width="1" height="1"&gt;</description></item><item><title>re: Null, Nothing, Empty </title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#89574</link><pubDate>Thu, 06 Apr 2006 16:55:30 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89574</guid><dc:creator>XTab's Blog</dc:creator><description>&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89574" width="1" height="1"&gt;</description></item><item><title>re: DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#89508</link><pubDate>Wed, 05 Apr 2006 23:34:22 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89508</guid><dc:creator>bill</dc:creator><description>Thanks Jonathan. I look forward to finding out why this happens.&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89508" width="1" height="1"&gt;</description></item><item><title>re: DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#89439</link><pubDate>Wed, 05 Apr 2006 17:41:19 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89439</guid><dc:creator>Jonathan de Halleux</dc:creator><description>I am the tester for the JIT. We are looking at the problem since it is most likely a bug on our side.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89439" width="1" height="1"&gt;</description></item><item><title>re: DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#89396</link><pubDate>Wed, 05 Apr 2006 16:13:06 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89396</guid><dc:creator>Darren Kopp</dc:creator><description>very interesting.  and to think that when you asked &amp;quot;have you spotted the problem?&amp;quot; all i could see was an if statement and a method call within a for loop :)&lt;br&gt;&lt;br&gt;c# rules!&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89396" width="1" height="1"&gt;</description></item><item><title>re: DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#89365</link><pubDate>Wed, 05 Apr 2006 06:36:14 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89365</guid><dc:creator>bill</dc:creator><description>Ayende,&lt;br&gt;&lt;br&gt;I beleive that the removal of the code that checks for null is the likely suspect.  It's that kind of optimisation that the JIT looks for when you allow it to optimise the code. Rember the JIT can inline code from other assemblies if it thinks it should.&lt;br&gt;&lt;br&gt;I have bugged the issue on MSDN feedback:&lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=a184aa36-55d5-45d3-a308-9c2240a175fe"&gt;http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=a184aa36-55d5-45d3-a308-9c2240a175fe&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89365" width="1" height="1"&gt;</description></item><item><title>re: DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#89364</link><pubDate>Wed, 05 Apr 2006 06:34:08 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89364</guid><dc:creator>bill</dc:creator><description>Kalpesh, yes fo course you can assign a null to a string as it is a reference type.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89364" width="1" height="1"&gt;</description></item><item><title>re: DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#89361</link><pubDate>Wed, 05 Apr 2006 06:24:44 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89361</guid><dc:creator>Kalpesh</dc:creator><description>Well, this might sound stupid.&lt;br&gt;&lt;br&gt;But, can you assign null to a string explicitly?&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89361" width="1" height="1"&gt;</description></item><item><title>re: DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#89358</link><pubDate>Wed, 05 Apr 2006 05:56:39 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89358</guid><dc:creator>Ayende Rahien</dc:creator><description>This doesn't make sense.&lt;br&gt;The IsNullOrEmpty is a static method that is built correctly.&lt;br&gt;The exception is not caused on the IsNullOrEmpty, but on the test() method.&lt;br&gt;On the for() line, as a matter of fact, and I can't understand why.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89358" width="1" height="1"&gt;</description></item><item><title>re: DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!</title><link>http://msmvps.com/blogs/bill/archive/2006/04/04/danger-string-isnullorempty-can-lead-to-runtime-null-exceptions.aspx#89357</link><pubDate>Wed, 05 Apr 2006 05:49:38 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89357</guid><dc:creator>bill</dc:creator><description>The JIT team hasn't officially said yet.  My guess is that the JIT is removing the check for null on the parameter being passed to String.IsNullOrEmpty as this is often superfulous&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89357" width="1" height="1"&gt;</description></item></channel></rss>