Visual Basic Case Insensitivity
December 13th, 2004

Here’s something that bit us today. Somehow, our big solution has been tricked into thinking that the System.Web.UI.Control.DataBind method is actually Databind (with a small “b”). It became impossible to type “DataBind” in Visual Studio without VB autocorrecting to “Databind.”

Most of the time, this didn’t matter an awful lot. However, when you do the following, you discover another one of those situations where VB helps you create behavior that is totally incomprehensible to and unfixable by your average VB programmer.

    Public Class SomeCtrl
        Inherits Control
        Public Overrides Sub Databind()
            ' do something fancy
        End Sub
    End Class
    ' ...
    Public Sub Test()
        Dim C As Control = New SomeCtrl
    End Sub


For us, that C.DataBind was calling the DataBind method in System.Web.UI.Control! The reason can be found in Reflector:

VB.Net compilation bug

Visual Basic was actually creating a NEW virtual method with the lowercase b. It was NOT overriding DataBind. Despite the overrides keyword, which I guess is just a compiler feature and not a CLR construct (the virtual in MSIL covers everything).

We fixed our issue by opening up scores of .vb files in emacs, updating them to have the uppercase B, and then by deleting all of the files in %systemroot%\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\ on all of our dev machines and our build machine.

Is this yet another artifact of an extremely large VB solution? I have no idea, but to me, compiler bugs are very scary.