开发者

How do I select the target framework of a CodeDom compiler using C#?

So I have a CodeDOM compiler written in C# that's supposed to compile another application based on one of its resources. How would I change the target .NET framework of the resource (or of the outputted executable of the compile开发者_高级运维r)?


You could pass options to the compiler using the following constructor:

var providerOptions = new Dictionary<string, string>();
providerOptions.Add("CompilerVersion", "v3.5");
var compiler = new CSharpCodeProvider(providerOptions);
...


You would need to specify it in a dictionary of settings for the compiler, such as:

var settings = new Dictionary<string,string>();
settings.Add("CompilerVersion", "v3.5");
var compiler = new CSharpCodeProvider(settings);  

Unsurprisingly, Google already brings up a couple of examples of this, too; here and here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜