Search code examples
c#.netvb.netdecompiler

Decompiled DLL - Clues to help tell whether it was C# or VB.NET?


When using something like DotPeek to decompile a DLL, how do I tell whether it was originally coded in VB.Net or C#?

I gather there's no easy way to tell, but that there may be tell-tale signs (ie. clues) in some of the decompiled code?


Solution

  • You can look for a reference to the Microsoft.VisualBasic library. If that is present, it's very probable that the code was made using VB. The library is sometimes included in C# projects also, but that is not very common. If the reference is not there, it's certainly not VB.

    (Well, it's possible to compile VB without the library using the command line compiler and special compiler switches, but that is extremely rare.)

    You can also check how frequently the VisualBasic library is used. In a regular VB program it would be used often, but in a C# program it would typically only be used for some specific task that isn't available in other libraries, like a DateDiff call.

    Any VB specific commands, like CInt or Mid will show up as calls to the VisualBasic library, and even the = operator when used on strings, will use the library. This code (where a and b are strings):

    If a = b Then
    

    will actually make a library call to do the comparison, and shows up like this when decompiled as C#:

    if (Operators.CompareString(a, b, false) == 0) {