简体   繁体   English

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

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

I'm using VS2010 and used NuGet to install Async CTP (Version 3, Unofficial) . 我正在使用VS2010,并使用NuGet来安装Async CTP(第3版,非官方) Then I copied some sample code: 然后我复制了一些示例代码:

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 doesn't give any errors on the use of async and await (it did show errors before I installed the package), so it looks promising. ReSharper在使用asyncawait没有给出任何错误(在我安装软件包之前确实显示了错误),因此它看起来很有希望。 But when I build the project, I get some syntax errors which I don't expect. 但是,当我构建项目时,会遇到一些意想不到的语法错误。

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

Is adding Async CTP (Version 3, Unofficial) via NuGet not enough to actually be able to compile the code? 通过NuGet添加异步CTP(版本3,非官方)是否不足以实际能够编译代码?

I must admit I don't know exactly what I'm doing here, was just trying to get some demo code to work. 我必须承认,我不完全知道我在这里做什么,只是想使一些演示代码正常工作。 The demo solution automatically installs the Async CTP via NuGet and seems to indicate there's nothing more I have to do. 该演示解决方案通过NuGet自动安装了Async CTP,似乎表明我不需要做任何其他事情。

From the NuGet page : NuGet页面

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

In other words, it appears to be only the support library, not the compiler. 换句话说,它似乎只是支持库,而不是编译器。

I would suggest you install either just .NET 4.5 - enough to play around from the command line - or some edition of Visual Studio 2012. There are various bugs in the CTP - it's much better to use the full release. 我建议您要么安装.NET 4.5(足以在命令行中运行),要么安装Visual Studio 2012的某些版本。CTP中存在各种错误,最好使用完整版本。

I don't think you can use just AsyncCTP package from NuGet to start developing Async/Await projects - you have to install the whole AsyncCTP using the regular installer . 我认为您不能仅使用NuGet的AsyncCTP软件包来开始开发Async / Await项目-您必须使用常规安装程序安装整个AsyncCTP。 That's because AsyncCTP requires updated compiler, not just this library. 这是因为AsyncCTP需要更新的编译器,而不仅仅是此库。

Also, as mentioned above, you should use Visual Studio 2012 and .NET 4.5 or Async Targeting Pack, if possible. 另外,如上所述,如果可能,您应该使用Visual Studio 2012和.NET 4.5或异步定位包。 And in case you are developing Windows Phone 7.1 project, you need to wait until public Windows Phone SDK for VS2012 is released together with updated Async Targeting Pack for Windows Phone 7.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