简体   繁体   中英

How do I safely use an obfuscator?

当我尝试在我的应用程序上使用dotfuscate时,运行时出现应用程序错误。

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.

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")]

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM