ऐसा लगता है कि WinRT से एक प्रकार का उपयोग करने की कोशिश कर रहे पुस्तकालयों क्योंकि StorageFile
class documentation बताता है कि यह केवल मेट्रो पर लागू होता है और यह Windows.Storage
में पाया जाता है।
This blog post इसे कैसे बनाया जाए, इसके माध्यम से चला जाता है, लेकिन यह एक मैन्युअल प्रक्रिया प्रतीत होता है। यह भी त्रुटि के कारण विवरण:
Using the await keyword causes the compiler to look for a GetAwaiter method on this interface. Since IAsyncOperation does not define a GetAwaiter method, the compiler wants to look for an extension method.
असल में, यह आप की तरह के लिए एक संदर्भ जोड़ने की जरूरत है दिखता है: System.Runtime.WindowsRuntime.dll
कृपया अपने ब्लॉग पोस्ट को पढ़ने के लिए समय लेने के लिए है, लेकिन मैं लूंगा स्पष्टता के लिए यहां महत्वपूर्ण हिस्सा डालें।
ब्लॉग unceremoniously चोरी के नीचे सामग्री
पहले, नोटपैड में, मैं EnumDevices.cs में निम्नलिखित सी # स्रोत कोड बनाया:
using System;
using System.Threading.Tasks;
using Windows.Devices.Enumeration;
using Windows.Foundation;
class App {
static void Main() {
EnumDevices().Wait();
}
private static async Task EnumDevices() {
// To call DeviceInformation.FindAllAsync:
// Reference Windows.Devices.Enumeration.winmd when building
// Add the "using Windows.Devices.Enumeration;" directive (as shown above)
foreach (DeviceInformation di in await DeviceInformation.FindAllAsync()) {
Console.WriteLine(di.Name);
}
}
}
दूसरा, मैं एक Build.bat बनाया फ़ाइल जो मैं इस कोड को बनाने के लिए डेवलपर कमांड प्रॉम्प्ट से चलाता हूं (यह 1 लाइन होनी चाहिए लेकिन मैं इसे पढ़ने की क्षमता के लिए यहां लपेटता हूं):
csc EnumDevices.cs
/r:c:\Windows\System32\WinMetadata\Windows.Devices.Enumeration.winmd
/r:c:\Windows\System32\WinMetadata\Windows.Foundation.winmd
/r:System.Runtime.WindowsRuntime.dll
/r:System.Threading.Tasks.dll
फिर, कमांड प्रॉम्प्ट पर, मैं आउटपुट देखने के लिए EnumDevices.exe चलाता हूं।
स्रोत
2012-05-03 09:30:42
मेट्रो शैली में, क्या कोड फ़ाइल के शीर्ष पर कोई अतिरिक्त विवरण हैं? –
वही उपयोग कर रहे हैं ... –