[英]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在使用async
和await
沒有給出任何錯誤(在我安裝軟件包之前確實顯示了錯誤),因此它看起來很有希望。 但是,當我構建項目時,會遇到一些意想不到的語法錯誤。
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.