I need to inject a custom, unique, static string into my .NET based EXE. For all intents and purposes, assume that this is my Private key of a PKI.
I have a few ideas on how I’ll approach protecting the Private key within the C# source code, my question is how do I take my .CS files and create an executable based off it?
Take a look at CSharpCodeProvider, which can essentially be used take a string containing source code and compile it to an assembly (EXE or DLL), or if you require, an in memory assembly.
You can also use the codeDOM for the code generation side of things. Take a look at ‘Generating Source Code and Compiling a Program from a CodeDOM Graph’ as a starting point.