Obfuscar .NET Obfuscation Breaks References to My.Computer

687 Views Asked by At

We are running .NET application with references to My.Computer in an Obfuscar obfuscated dll. It seems that these references throw an exception at run time. For instance:

Code:

Dim str As String = My.Computer.Name

Message:

The type initializer for 'a.aa' threw an exception.

Inner Exception:

   System.MissingFieldException: Field not found: 'a`1.W'.
   at a.aa.a`1..ctor()
   at a.aa..cctor()

From these error messages, it looks like Obfuscar is obfuscating the reference to My.Computer.Name. (.NET Reflector shows aa.A.Name.) I'm not sure how that makes sense since it's an "external" reference.

Using a different way to get the computer name does appear to work, but we have a lot of references to My.Computer in our code, and it would be good to figure out how to get Obfuscar to not break these, rather than have to tiptoe around them.

I think I am looking for an Obfuscar XML entry to skip these references, unless anyone has any better ideas.

1

There are 1 best solutions below

2
On BEST ANSWER

In case anyone finds this, our solution was to set the following flag to false:

<Var name="HidePrivateApi" value="false" />

This obviously reduces some of the security of the obfuscation, but it solved our issue for now.