0

We have developed project using vb.net for our internal purposes and then we obfuscated it. It is throwing error as mentioned below.

“Public member ‘Var1’ on type ‘e’ not found.”

Code:

Public Sub get_constants_from_DbList(ByRef frm As Object, ByRef sDbname As String)

    For Each Row As DataRow In CommonObj.DSCommonProc.Tables("dblist").Rows 
            If StrComp(Row("DbName").ToString, sDbname, CompareMethod.Text) = 0 Then
             prg_id = Row("PrgId").ToString
             frm.Var1= Row("ChangesDbName").ToString
             frm.Var2 = Row("LoadTableName").ToString
             frm.Var3 = Row("ServerName").ToString
             Exit Sub
        End If
    Next

End Sub

A form (named FrmMain) is passed to the parameter ‘frm’ from the calling procedure to this sub-routine. Var1, etc are public variables in that form.

Obfuscation tools we tried are –

  1. SmartAssembly 6

  2. PreEmptive Dotfuscator and Analytics CE (which has come with Visual studio 2012)

Without obfuscation exe is working fine.

Error is thrown while assigning variable ‘Var1’ in the sub-routine. If the code line is modified as below then obfuscated exe will work fine.

FrmMain.Var1= Row("ChangesDbName").ToString

We thought obfuscation is missing late binding & tried similar type of code in a small sample project. But that didn’t have any error. We have attached this small code. But due to its magnitude we can’t upload original project.

How can we trace the error?

You can find the source code of my sample application here

IT researcher
  • 3,274
  • 17
  • 79
  • 143

2 Answers2

1

Don't use obfuscation with reflection/late binding/dynamic. It will only get you into troubles like this.

The obfuscator will obfuscate all private & internal identifiers but it can't know that you are binding to them by name at run-time.

Turn on Option Strict and resolve the errors (i.e. change the type of the argument frm to its real type)

adrianm
  • 14,468
  • 5
  • 55
  • 102
0

Obfuscators rely on static analysis to determine what is "safe" to obfuscate. When you introduce late binding and reflection into the mix, it becomes very difficult to detect that something isn't safe to rename. Most obfuscators provide the ability to exclude certain elements of your application from obfuscation so that you can work around this problem.

I actually don't know VB.Net very well, but with the way that you're doing late binding appears to be something that an obfuscator can't detect. So, this means you need to exclude that property from being renamed. In Dotfuscator at least, this is should be easy. You should also be able to turn on "Library Mode" which will automatically exclude all public members of every class.

Earlz
  • 62,085
  • 98
  • 303
  • 499