Visual Studio 2008无法识别Lambda表达式语法 [英] Visual Studio 2008 doesn't recognize Lambda Expression Syntax

查看:337
本文介绍了Visual Studio 2008无法识别Lambda表达式语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用内置的转换工具将Web应用程序项目(以及一些相关项目)从.net 2.0升级到.net 3.5。一切正常,例如使用MS AJAX 3.5与2.0中的外部MS AJAX库。

I recently upgraded a Web Application Project (as well as some dependent projects) from .net 2.0 to .net 3.5 using the built in conversion tool. Everything works well such as using MS AJAX 3.5 vs. the external MS AJAX libraries in 2.0.

当我尝试使用新的Lambda Expression语法时,会出现问题。编译器不会将Lambda表达式识别为有效语法。在该解决方案的所有项目中,目标框架版本均设置为3.5。我还能够在同一解决方案的库项目中成功使用Lambda表达式。

My problem occurs when I tried using the new Lambda Expression syntax. The compiler will not recognize Lambda Expressions as valid syntax. The target frame work version is set to 3.5 in all projects in the solution.I was also able to successfully use Lambda Expressions in a Library Project in the same solution.

是给我错误的代码。没什么特别的。

The is the code that is giving me the error. Nothing too special.

ObjectFactory.Initialize(x => 
        {
            x.ForRequestedType<IUnitIdSequencingService>().TheDefaultIsConcreteType<UnitIdSequencingService>();
            x.ForRequestedType<IGadgetDAO>().TheDefault.Is.OfConcreteType<GadgetDAO>().WithCtorArg("instance").EqualToAppSetting("OSHAInspectionManager");

        });

我遇到的具体错误是:

Error   102 Invalid expression term '>' D:\projects\bohlco\pmr\PMR\Web\App_Code\Bootstrapper.cs 13  41  D:\...\Web\

任何帮助将不胜感激。我一直在运气不错的情况下搜索Google

Any help would be greatly appreciated. I have been searching Google with little luck

推荐答案

如果ASP.NET正在编译任何页面(即您不是 t预编译WAP),则需要确保ASP.NET了解C#3.0(.NET 3.5)编译器。确保以下内容位于 web.config

If any of the page is being compiled by ASP.NET (i.e. you aren't pre-compiling the WAP), then you'll need to ensure that ASP.NET knows about the C# 3.0 (.NET 3.5) compiler. Ensure the following is in the web.config:

<system.codedom>
   <compilers>
      <compiler language="c#;cs;csharp"
            extension=".cs"
            warningLevel="4"
            type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=
         <providerOption name="CompilerVersion" value="v3.5"/>
         <providerOption name="WarnAsError" value="false"/>
      </compiler>
   </compliers>
</system.codedom>

此外,如果您在IIS中托管,请确保将正确的文件夹设置为应用程序,并且使用的是ASP.NET v2.blah(而非v1.1.blah) )。

Also, if you are hosting in IIS, ensure that the correct folder is set as an application, and that it is using ASP.NET v2.blah (not v1.1.blah).

这篇关于Visual Studio 2008无法识别Lambda表达式语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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