2015-01-03 26 views
3

我已經將同一段代碼從一個項目複製到另一個,並且在第一個代碼中它編譯得很好,但是在第二個代碼中沒有。錯誤:await需要該類型有一個合適的GetAwaiter方法

這件作品是:

using Windows.Devices.Bluetooth; 
// a couple of lines of other code 
var rfcommProvider = await RfcommServiceProvider.CreateAsync(RfcommServiceId.FromUuid(RfcommChatServiceUuid)); 

錯誤:

'await' requires that the type 'Windows.Foundation.IAsyncOperation<Windows.Devices.Bluetooth.Rfcomm.RfcommServiceProvider>' have a suitable GetAwaiter method. Are you missing a using directive for 'System'? 

第一個項目是由微軟創建的演示,這是一個Windows應用程序8.1。

我的應用程序是正常的WPF應用程序,它的目標是.NET 4.5.1和Windows 8.1和我加了參考Windows.winmd描述here

我不知道爲什麼同一段代碼可能編譯在一個應用程序中,而不是在另一個應用程序中編譯時,如引用,名稱空間等所有常見的東西都可以。我唯一的想法是,也許我引用了一些尚未等待的舊版本,但我不知道如何驗證這一點。

+0

在非地鐵[StorageFile異步的使用可能重複應用](http://stackoverflow.com/questions/10428446/storagefile-async-usage-in-a-non-metro-application) –

回答

相關問題