简体   繁体   English

如果我没有使用CSharpCodeProvider指定CompilerVersion,为什么大多数样本都指定它,会发生什么?

[英]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.

相关问题 如果我没有在字符串属性上指定StringLength或MaxLength会发生什么? - What happens if I don't specify StringLength or MaxLength on a string property? C#:为什么当我们不指定泛型时,泛型不使用它可以使用的最泛型类型? - C#: Why don't generics use the most generic type it can when we don't specify one? 将N个元素插入到列表中的复杂性顺序是什么 <T> 如果我不指定容量? - What is the order of complexity of inserting N elements into a List<T> if I don't specify a capacity? 如果我不调用dispose()会发生什么? - What happens if i don't call dispose()? 如果我不等待任务会怎样? - What happens if I don't await a task? 为什么需要指定裁剪分辨率? - Why do I need to specify a resolution for cropping? PropertyGrid-如果我无法控制该类,请指定ExpandableObject - PropertyGrid - Specify ExpandableObject if I don't have control of the class 如何使用CSharpCodeProvider获取写到控制台的内容 - How do I grab what is written to console with CSharpCodeProvider 如果我不在笔对象上调用Dispose会发生什么? - What happens if I don't call Dispose on the pen object? 如果我不实现部分方法会怎样? - what happens if I don't implement a partial method?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM