First bug in the .NET Framework 2.0 ??

Written by Yves

May 10, 2006

Currently developping a little application using the Framework 2.0 and the System.IO.Ports.SerialPort class, I got this nice exception when trying to set the StopBits property of my SerialPort instance to StopBits.None :



Quite strange, isn’t it ?


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, Reflector, 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 :



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.One, it throws the ArgumentOutOfRangeException. Maybe the guy who wrote this code forgot to add a “N” at the beginning of the enum value….


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.


If anyone reading this post has an answer, I would appreciate at its own value and I thank you for your comments….

You May Also Like…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *