从源代码动态创建一个编译的.NET exe? [英] Dynamically create a compiled .NET exe from source code?

查看:167
本文介绍了从源代码动态创建一个编译的.NET exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要注入一个自定义,唯一的静态字符串到我的基于.NET的EXE。对于所有的意图和目的,假设这是我的私钥的PKI。

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.

我有几个想法如何将保护私钥在C#源代码,我的问题是我如何拿走我的.CS文件,并创建一个可执行文件关闭它?

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?

推荐答案

CSharpCodeProvider ,其实质上可以使用包含源代码的字符串,并将其编译到程序集(EXE或DLL),或者如果需要,在内存汇编中。

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.

还可以使用 codeDOM 的代码生成方面的事情。请查看从CodeDOM图生成源代码和编译程序作为起点。

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.

这篇关于从源代码动态创建一个编译的.NET exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆