Subtle bug, VB style
-
I am writing a web-based message forum using the language I know best, Visual Basic. I have an xml file that maps the codes for inserting a smiley emoticon to the corresponding image file. This is what I wrote to initialize the object that holds this data:
pSmileyList = New SortedDictionary(Of String, String)
Dim Smileys As XDocument = XDocument.Load(Constants.SmileyImages + "index.xml")
Dim Code As String = ""
Dim Image As String = ""For Each S As XElement In Smileys...<Smiley>
Code = S.@code
Image = S.@image
pSmileyList.Add(Code, Image)
NextBut the darn thing would not work: when it hit the
For Each
block, it jumped out andpSmileyList
never got loaded. After nearly an hour of metaphorically banging my head against the wall, I figured out the problem and nearly banged my head against the wall for real. Visual Basic is not case sensitive. XML is. I am used to case not mattering. In VB, there is no difference at all betweenSmiley
andsmiley
. In XML -- and therefore, in LINQ -- there is a difference. Yup: it took me an hour to realize that was using<smiley>
in the XML file, and that the problem could be fixed by usingSmileys...<smiley>
in my initialization. :doh: Edited for spelling. -
I am writing a web-based message forum using the language I know best, Visual Basic. I have an xml file that maps the codes for inserting a smiley emoticon to the corresponding image file. This is what I wrote to initialize the object that holds this data:
pSmileyList = New SortedDictionary(Of String, String)
Dim Smileys As XDocument = XDocument.Load(Constants.SmileyImages + "index.xml")
Dim Code As String = ""
Dim Image As String = ""For Each S As XElement In Smileys...<Smiley>
Code = S.@code
Image = S.@image
pSmileyList.Add(Code, Image)
NextBut the darn thing would not work: when it hit the
For Each
block, it jumped out andpSmileyList
never got loaded. After nearly an hour of metaphorically banging my head against the wall, I figured out the problem and nearly banged my head against the wall for real. Visual Basic is not case sensitive. XML is. I am used to case not mattering. In VB, there is no difference at all betweenSmiley
andsmiley
. In XML -- and therefore, in LINQ -- there is a difference. Yup: it took me an hour to realize that was using<smiley>
in the XML file, and that the problem could be fixed by usingSmileys...<smiley>
in my initialization. :doh: Edited for spelling. -
At least he's not using VB6 and INI files, right?
Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)
-
:flame: XML is awesome! Unless you abuse it, I guess.
-
I am writing a web-based message forum using the language I know best, Visual Basic. I have an xml file that maps the codes for inserting a smiley emoticon to the corresponding image file. This is what I wrote to initialize the object that holds this data:
pSmileyList = New SortedDictionary(Of String, String)
Dim Smileys As XDocument = XDocument.Load(Constants.SmileyImages + "index.xml")
Dim Code As String = ""
Dim Image As String = ""For Each S As XElement In Smileys...<Smiley>
Code = S.@code
Image = S.@image
pSmileyList.Add(Code, Image)
NextBut the darn thing would not work: when it hit the
For Each
block, it jumped out andpSmileyList
never got loaded. After nearly an hour of metaphorically banging my head against the wall, I figured out the problem and nearly banged my head against the wall for real. Visual Basic is not case sensitive. XML is. I am used to case not mattering. In VB, there is no difference at all betweenSmiley
andsmiley
. In XML -- and therefore, in LINQ -- there is a difference. Yup: it took me an hour to realize that was using<smiley>
in the XML file, and that the problem could be fixed by usingSmileys...<smiley>
in my initialization. :doh: Edited for spelling.I know just what you mean. I'm playing around in Ubuntu and it's command line is case sensitive as well as the directory structure and filenames. I don't know how many times I think to myself "I know that file should be there!" only to realize that it's the case. I like to name files with CapsForEachWord so that it's easy to read but I like to just type in lower case to access for convenience. It's hard to change a habit If your anything like me you'll have that problem again unless you do allot of VB/XML
-
:flame: XML is awesome! Unless you abuse it, I guess.
Oh yeh. Xml is AWESOME. But VB.NET used on Xml is what sucks. ;) OK Stryder, I deflected the flames to myself.
-
Oh yeh. Xml is AWESOME. But VB.NET used on Xml is what sucks. ;) OK Stryder, I deflected the flames to myself.
Michael Eber wrote:
But VB.NET used on Xml is what sucks
I'm not sure XML enters into it. :~