CSharpCodeProvider after Obfuscator

595 views Asked by At

I'm using a Scripting system that compile at runtime, it is working good, but when I use some code obfuscator to hide my codes from "bad guys" the scripting stop to work, it returns an error:

Error: CS0234

The type or namespace name "Objects" does not exist in the namespace "TestProgram" (are you missing an assembly reference?)

Error: CS0246

The type or namespace name "Scripter" could not be found (are you missing a using directive or an assembly reference?)

Do you know if there is a way to fix it? I tried a lot of obfuscators, and look's like that all does the same thing with my scripter.

1

There are 1 answers

5
Reed Copsey On BEST ANSWER

You most likely need to not obfuscate the public types your "scripts" try to access.

This can be done with most better obfuscators by including the appropriate attribute (ObfuscationAttribute) with the Exclude property set to true on the types or methods as needed: [Obfuscation(Exclude=true)]


Edit:

You would use this attribute by decorating the appropriate types, as needed, ie:

[Obfuscation(Exclude=true, ApplyToMembers=true)]
public class Objects
{
    // ... 

This will cause most obfuscators (though some require configuration to pay attention to this attribute) to not obfuscate the type. Some obfuscators will obfuscate the internal members, but not obfuscate the public API. This depends on the actual tool you are using, and I would recommend seeing their documentation for specifics.