After reading the ins and outs of compilation differences between C# and C++ , my question is, cant we compile the C#application (or dll) with Visual Studio (or with other program), so similarly to C++ it stripped out many information during compilation and made an app which will be hard for decompilation like C++ file.

1 Answer 1


There are a number of options:

  • C# code can be compiled to native code (like C++ compilation) using Ngen.exe or .NET Native. Although the IL code and metadata might still be required by the runtime.
  • All kinds of information that is contained in an assembly such as type names, variable names, method names, strings, and constants can be obfuscated. This makes the purpose of a construct difficult to guess just by looking at its name. This makes an assembly more like a native binary that is stripped of debugging information, except that IL code is still much easier to decompile than native code in general. IL instructions cannot be obfuscated as easily.
  • Obfuscate or encrypt everything "managed" including the IL code and modify the native entry point of the assembly so that it calls a native function that will deobfuscate or decrypt (potentially on-demand or as-needed) IL code and metadata. The native function may call an external native library to do the job. This obviously makes decompilation much harder than even decompiling plain native code, but it comes at a run-time performance cost when execute the code. The previous two techniques have basically no performance overhead.
  • 1
    thanks, nice answer. However, if you have given methods (examples) how to do each thing you are describing, should have been excellent answer!
    – T.Todua
    May 5, 2018 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.