可选的和命名的参数,MVC2中的语言规范

时间:2021-10-03 10:51:10

I'm using MVC2 in a mixed webforms project, my Model classes compile fine with optional and named parameters, but my view won't compile when using them. I get:

我在一个混合的webforms项目中使用MVC2,我的模型类很好地使用可选和命名参数进行编译,但是我的视图在使用它们时不会编译。我得到:

Error 38 Feature 'named argument' cannot be used because it is not part of the 3.0 C# language specification

不能使用Error 38特性“named argument”,因为它不是3.0 c#语言规范的一部分

Any ideas? Thanks

什么好主意吗?谢谢

1 个解决方案

#1


1  

Your app will need to be configured to run in ASP.NET 4.x rather than 2.x; you might also want (in your web.config):

您的应用程序需要配置为在ASP中运行。净4。而不是2. x;您可能还需要(在您的web.config中):

  <system.codedom>
    <compilers>
      <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>
    </compilers>
  </system.codedom>

You might get away without this if you pre-compile your views.

如果你预先编译你的视图,你可能不需要这个。

#1


1  

Your app will need to be configured to run in ASP.NET 4.x rather than 2.x; you might also want (in your web.config):

您的应用程序需要配置为在ASP中运行。净4。而不是2. x;您可能还需要(在您的web.config中):

  <system.codedom>
    <compilers>
      <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>
    </compilers>
  </system.codedom>

You might get away without this if you pre-compile your views.

如果你预先编译你的视图,你可能不需要这个。