A careful gotcha when referencing VB.NET code from C#

When referencing VB.NET code from C#.NET there is a subtle but very important difference between the two.

This was found when I was trying to access some legacy VB.NET code that used reflection to interact with two classes with nearly the same name. The VB.NET code worked perfectly fine but I was faced with a compiler error when trying to call the code from a new C#.NET project.

The error to watch out for is

CS0234 C# The type or namespace name does not exist in the namespace (are you missing an assembly reference?)

This comes down to the case sensitivity differences between VB.NET and C#.NET. In VB.NET the casing on class names is not important. So a class with the name VbCasingExample is the same as the class vbcasingexample. However in C#.NET these are two very different classes as identifier casing is important.

VbCasing.PNG

Compared to

CSharpCasing.PNG

So be careful when referencing VB.NET code from any case sensitive .NET language.