编程语言
首页 > 编程语言> > c#-错误显示在“ async”关键字附近,但构建成功

c#-错误显示在“ async”关键字附近,但构建成功

作者:互联网

当我编译未打开任何文件的项目时,构建将按预期成功.现在,当我使用async关键字打开包含任何方法的文件时,在我的错误窗口中会显示以下消息:

Error   6   ; expected  
Error   10  ; expected  
Error   16  A namespace cannot directly contain members such as fields or methods   
Error   2   Identifier expected

当我构建解决方案时,它仍然成功.

我安装了AsyncCTPv3和ReSharper.我目前禁用了ReSharper,但仍然显示这些错误.任何线索?

编辑:相同的错误似乎在await关键字附近出现.我的意思是等待和异步并存,但是这些错误只发生在非.NET-4.0元素旁边,这很奇怪.而且编译器甚至根本不在乎.我认为只是Visual Studio难以解释这些关键字.

解决方法:

首先.非常感谢Joshua Drake,他提供了link.首先,我意识到我的文件版本与应该存在的版本不匹配.我重新安装没有任何成功.之后,我在该站点上注意到以下段落:

Run Windows Update before installing Async CTP v3, and get all updates
(including Optional updates) from before October 2011

BUT NONE that came after. Three in particular, KB2635973 and KB2615527 and KB2645410, are known to be incompatible with Async CTP
v3.

After installing Async CTP v3, then you can get subsequent updates.

这就是线索.卸载上述三个更新后,我再次重新安装了Async CTP,它可以正常工作.非常感谢!

标签:asynchronous,async-ctp,c,net,visual-studio
来源: https://codeday.me/bug/20191201/2080177.html