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

风格不统一 提交于 2019-12-05 04:12:55

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!