3

I am currently writing a class that uses the async..await-Pattern to do asynchronous tasks. In it I have a method like so:

public async void DoSomething() {
  ...
  await SomeObject.DoYourThingAsync();
  ...
}

For the reference: The project is set to use .NET-Framework 4.5 and I am using VS2012. On my machine it compiles and works just fine, but when I check it into TFS, the build generates an error in the declaration of the function. The message is: Invalid token 'void' in class, struct, or interface member declaration

4

1 回答 1

4

看起来您的构建服务器不理解 C#5 语法。对于 C# 4 编译器async void(或async Task就此而言),您似乎指定了两种返回类型。

重新配置服务器上的构建以使用 C# 5 语法或更新版本的编译器。

于 2013-09-05T11:30:06.250 回答