繁体   English   中英

NuGet程序包Async CTP(版本3,非官方)在等待和异步时出现编译错误

[英]NuGet package Async CTP (Version 3, Unofficial) compiliation error on await and async

我正在使用VS2010,并使用NuGet来安装Async CTP(第3版,非官方) 然后我复制了一些示例代码:

using System.Threading.Tasks;

namespace ConsoleApplication5AsyncCtp
{
    internal class Program
    {
        private static void Main(string[] args)
        {
        }

        public async Task<int> GetValue()
        {
            await TaskEx.Delay(100);
            return 13; // Return type is "int", not "Task<int>"
        }
    }
}

ReSharper在使用asyncawait没有给出任何错误(在我安装软件包之前确实显示了错误),因此它看起来很有希望。 但是,当我构建项目时,会遇到一些意想不到的语法错误。

Program.cs(15,32): error CS1003: Syntax error, '(' expected
Program.cs(15,40): error CS1001: Identifier expected
Program.cs(17,32): error CS1031: Type expected
Program.cs(21,1): error CS1022: Type or namespace definition, or end-of-file expected

通过NuGet添加异步CTP(版本3,非官方)是否不足以实际能够编译代码?

我必须承认,我不完全知道我在这里做什么,只是想使一些演示代码正常工作。 该演示解决方案通过NuGet自动安装了Async CTP,似乎表明我不需要做任何其他事情。

NuGet页面

Visual Studio Async CTP Samples文件夹中的AsyncCtpLibrary.dll

换句话说,它似乎只是支持库,而不是编译器。

我建议您要么安装.NET 4.5(足以在命令行中运行),要么安装Visual Studio 2012的某些版本。CTP中存在各种错误,最好使用完整版本。

我认为您不能仅使用NuGet的AsyncCTP软件包来开始开发Async / Await项目-您必须使用常规安装程序安装整个AsyncCTP。 这是因为AsyncCTP需要更新的编译器,而不仅仅是此库。

另外,如上所述,如果可能,您应该使用Visual Studio 2012和.NET 4.5或异步定位包。 并且,如果您正在开发Windows Phone 7.1项目,则需要等到VS2012的公共Windows Phone SDK与更新的Windows Phone 7.5异步定位包一起发布。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM