Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6824305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:53:09+00:00 2026-05-26T21:53:09+00:00

I was debugging one of the applications I work on and came across an

  • 0

I was debugging one of the applications I work on and came across an interesting issue. For those unfamiliar with VB.NET, variable names are case insensitive. Therefore,

Dim foo As Integer
FOO = 5
System.Console.WriteLine(foO)

will compile and output a value of 5.

Anyways, the code I was working on was attempting to get a value from a property via reflection like so:

Dim value As Object = theObject.GetType().GetProperty("foo", BindingFlags.Public Or BindingFlags.Instance).GetValue(theObject, Nothing)

The code threw a NullReferenceException on this line. After doing some debugging, I noticed it is the GetProperty method that is returning Nothing, so GetValue is bombing. Looking at the class for theObject, it has a public property with the name “Foo”, not “foo” (notice the difference in casing). Apparently, since I was searching for lowercase foo, it could not find the property at all via reflection.

Thinking this was some weird fluke, I created a quick and dirty sandbox app to test this finding:

Option Strict On
Option Explicit On

Imports System.Reflection

Module Module1

    Sub Main()
        Dim test As New TestClass
        Dim propNames As New List(Of String)(New String() {"testprop", "testProp", "Testprop", "TestProp"})

        'Sanity Check
        System.Console.WriteLine(test.testprop)
        System.Console.WriteLine(test.testProp)
        System.Console.WriteLine(test.Testprop)
        System.Console.WriteLine(test.TestProp)

        For Each propName As String In propNames
            Dim propInfo As PropertyInfo = test.GetType().GetProperty(propName, BindingFlags.Public Or BindingFlags.Instance)
            If propInfo Is Nothing Then
                System.Console.WriteLine("Uh oh! We don't have PropertyInfo for {0}", propName)
            Else
                System.Console.WriteLine("Alright, we have PropertyInfo for {0} and its value is: {1}", propName, propInfo.GetValue(test, Nothing))
            End If
        Next
    End Sub

    Public Class TestClass
        Private _testProp As String = "I got it!"
        Public Property TestProp() As String
            Get
                Return _testProp
            End Get
            Set(ByVal value As String)
                _testProp = value
            End Set
        End Property
    End Class

End Module

Much to my surprise, the output was as follows:

I got it!
I got it!
I got it!
I got it!
Uh oh! We don't have PropertyInfo for testprop
Uh oh! We don't have PropertyInfo for testProp
Uh oh! We don't have PropertyInfo for Testprop
Alright, we have PropertyInfo for TestProp and its value is: I got it!

TL;DR

Variable names in VB.NET are typically case insensitive. The GetProperty method on Type seems to be case sensitive when it comes to the property name. Is there a way to call this method “VB.NET style” and ignore case? Or am I SOL here and need to apply a C# mentality and worry about casing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:53:09+00:00Added an answer on May 26, 2026 at 9:53 pm

    Variable names in VB.NET are typically case insensitive.

    That’s a trick done by the compiler. The CLR itself is case-sensitive. Since reflection has nothing to do with the compiler, case-sensitivity applies.

    Is there a way to call this method “VB.NET style” and ignore case?

    Yes. Specify in your BindingFlags to IgnoreCase:

    Dim propInfo As PropertyInfo = test.GetType().GetProperty(propName, BindingFlags.Public Or BindingFlags.Instance Or BindingFlags.IgnoreCase)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of breakpoints which I used for debugging one issue. When
Context: I am currently debugging an issue where the binaries generated in one machine
I have one legacy web application based on struts2 (primarily using annotation). While debugging
As I was debugging and optimizing one of my C/C++-projects, I often disabled and
One of my favourite debugging features of SCSS is the @warn and @debug directives,
One of my pet peeves with debugging Perl code (in command line debbugger, perl
So one of the common tasks that I do as a programmer is debugging
Debugging an iterator method in VS2010 SP1 (with DEBUG settings... no compiler optimization), one
This probably has a one click solution, i know debugging web pages in VS2010
I am debugging this piece of software for an STM32 embedded system. In one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.