{"id":1869,"date":"2006-05-10T22:18:14","date_gmt":"2006-05-10T21:18:14","guid":{"rendered":"https:\/\/yvespeneveyre8e29bf869d.wordpress.com\/2006\/05\/10\/first-bug-in-the-net-framework-2-0\/"},"modified":"2006-05-10T22:18:14","modified_gmt":"2006-05-10T21:18:14","slug":"first-bug-in-the-net-framework-2-0","status":"publish","type":"post","link":"https:\/\/www.peneveyre.com\/en\/2006\/05\/10\/first-bug-in-the-net-framework-2-0\/","title":{"rendered":"First bug in the .NET Framework 2.0 ??"},"content":{"rendered":"<p><P><FONT color=\"#000000\">Currently developping a little application using the <A href=\"http:\/\/msdn2.microsoft.com\">Framework 2.0<\/A> and the <A href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/system.io.ports.serialport(VS.80).aspx\">System.IO.Ports.SerialPort<\/A> class, I got this nice exception when trying to set the <A href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/system.io.ports.serialport.stopbits(VS.80).aspx\">StopBits<\/A> property of my SerialPort instance to StopBits.None :<\/FONT><\/P><br \/>\n<P><IMG alt=\"\" hspace=\"0\" src=\"http:\/\/www.peneveyre.com\/en\/wp-content\/uploads\/sites\/3\/2023\/02\/StopBitsException.jpg\" align=\"baseline\" border=\"0\"><\/P><br \/>\n<P>Quite strange, isn&#8217;t it ?<\/P><br \/>\n<P>Knowing that GIMF, nothing to read about this problem, or a little in the mono version of .NET. So, I launched one of my favourite tool, <A href=\"http:\/\/www.aisto.com\/roeder\/dotnet\/\">Reflector<\/A>, to see inside the System.dll (Version 2.0.0.0 in the Framework version v2.0.50727) assembly. And here is the result when we look at the set_StopBits sub :<\/P><br \/>\n<P><IMG alt=\"\" hspace=\"0\" src=\"http:\/\/www.peneveyre.com\/en\/wp-content\/uploads\/sites\/3\/2023\/02\/StopBitsSource.jpg\" align=\"baseline\" border=\"0\"><\/P><br \/>\n<P>As we can see, before setting the property to the value passed in parameter, a little check is done on its value. And if that value is less than StopBits.<STRONG>O<\/STRONG>ne, it throws the ArgumentOutOfRangeException. Maybe the guy who wrote this code forgot to add a &#8220;N&#8221; at the beginning of the enum value&#8230;.<\/P><br \/>\n<P>Or, if it is what they really wanted to implement, nothing in the documentation is telling it is forbidden to set the StopBits property to None.<\/P><br \/>\n<P>If anyone reading this post has an answer, I would appreciate at its own value and I thank you for your comments&#8230;.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am not sure, but I maybe found a bug in the System.IO.Ports.SerialPort class implementation. Indeed, setting the StopBits property of that class to StopBits.None is causing an ArgumentOutOfRange exception.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1869","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.peneveyre.com\/en\/wp-json\/wp\/v2\/posts\/1869","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.peneveyre.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.peneveyre.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.peneveyre.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.peneveyre.com\/en\/wp-json\/wp\/v2\/comments?post=1869"}],"version-history":[{"count":0,"href":"https:\/\/www.peneveyre.com\/en\/wp-json\/wp\/v2\/posts\/1869\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.peneveyre.com\/en\/wp-json\/wp\/v2\/media?parent=1869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.peneveyre.com\/en\/wp-json\/wp\/v2\/categories?post=1869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.peneveyre.com\/en\/wp-json\/wp\/v2\/tags?post=1869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}