如何选择使用C#中的CodeDOM编译器的目标框架? [英] How do I select the target framework of a CodeDom compiler using C#?

查看:353
本文介绍了如何选择使用C#中的CodeDOM编译器的目标框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我写在C#中的CodeDOM编译器是应该编译基于它的资源之一另一个应用程序。我将如何改变资源的目标NET框架(或编译器的输出可执行的)?

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 compiler)?

推荐答案

您可以通过使用下面的构造编译器选项:

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);
...

这篇关于如何选择使用C#中的CodeDOM编译器的目标框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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