views:

632

answers:

4

When I attempt to use dotfuscate on my application, I get an application error when I run it.

+7  A: 

Most of the problem I have encountered with obfuscation revolve around types that can't have their name changed, because something needs to reflect on them (your code or the runtime).

for example if you have a class that is being used as a web service proxy, you can't safely obfuscate the class name:

public class MyWebServiceProxy : SoapHttpClientProtocol
{

}

Also some obfuscators can not handle generic methods and classes.

The trick is you need to find these types and prevent the obfuscater from renaming them. This is done with the Obfuscation attribute:

[global::System.Reflection.Obfuscation(Exclude=true, Feature="renaming")]
Greg Dean
+6  A: 

Dotfuscator (and all obfuscators) are typically safe to run on an application, but they do occasionally cause problems. Without specific details of your problem, it's difficult to diagnose.

However, one common problem with obfuscators is when you mix them with reflection. Since you're changing the type names, but not strings, any time you try to reflect on objects with a specific string name, and use the reflection namespace to construct objects, you'll likely have problems.

Reed Copsey
I'm just curious - but why the downvote? It'd be nice to know why people disagree...
Reed Copsey
A: 

Another thing that can be a problem with obfuscators is serialization using BinaryFormatter, since it changes the field names. I have some users who use protobuf-net for serialization on their obfuscated code for this reason.

Marc Gravell
A: 

You might want to take a look at an answer I posted here in SO.

ileon