[英]What happens if I don't specify CompilerVersion with CSharpCodeProvider and why do most samples specify it?
Typical code samples using CSharpCodeProvider
pass CompilerVersion
parameter. 使用CSharpCodeProvider
典型代码示例传递CompilerVersion
参数。 Code from here : 代码来自 :
var codeProvider =
new CSharpCodeProvider(
new Dictionary<String, String> { { "CompilerVersion", "v3.5" } });
I've tried to pass an empty dictionary and also tried to call the parameterless constructor of CSharpCodeProvider
and the result is the same. 我试图传递一个空字典,并试图调用CSharpCodeProvider
的无参数构造函数,结果是一样的。
So what happens internally if I don't specify `CompilerVersion? 那么如果我没有指定`CompilerVersion,内部会发生什么? Why do most samples specify it at all times? 为什么大多数样品始终指定它?
The documentation states that it gets it from either the machine.config
or the web.config
specified in your framework config folder. 文档说明它是从machine.config
或框架配置文件夹中指定的web.config
获取的。
For example, my Framework64/config/web.config file contains this: 例如,我的Framework64 / config / web.config文件包含以下内容:
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v4.0"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.