I have a .NET C# application which should be run only on one computer with known configuration (HP DL120 G7, Xeon E3-1220, Windows Server 2008 R2 Foundation if this is important). I don’t need to run this application on other computers.
I want to:
- make it as fast as possible (i.e. probably compile with “use Xeon E3-1220” key or something?)
- secure it a little bit (it should not be trivial to restore C# source code from binaries).
Should I compile to native Windows code somehow? Probably I should use some special compiler options?
You can compile it in “Release” mode to enable optimizations. Also, you can run ngen.exe to generate native DLLs which will not incur the overhead of JIT.
However, keep in mind that all these measures and tools are not a silver bullet for a poorly written code (not saying that yours is). You should profile your app and see if you can improvise the execution time of any code path as well as find out the slower paths (and seek to improve them).
To secure it, use a good obfuscator such as (Salamander, SmartAssembly etc.). It won’t be entirely indiscernible but it’ll make it lot more harder.
To absolutely secure it, code it in C++! You can compile it with
/clroption which will make them immune to reflection and disassembly.