<small id='qMTTE'></small><noframes id='qMTTE'>

        <bdo id='qMTTE'></bdo><ul id='qMTTE'></ul>
      <i id='qMTTE'><tr id='qMTTE'><dt id='qMTTE'><q id='qMTTE'><span id='qMTTE'><b id='qMTTE'><form id='qMTTE'><ins id='qMTTE'></ins><ul id='qMTTE'></ul><sub id='qMTTE'></sub></form><legend id='qMTTE'></legend><bdo id='qMTTE'><pre id='qMTTE'><center id='qMTTE'></center></pre></bdo></b><th id='qMTTE'></th></span></q></dt></tr></i><div id='qMTTE'><tfoot id='qMTTE'></tfoot><dl id='qMTTE'><fieldset id='qMTTE'></fieldset></dl></div>
      1. <tfoot id='qMTTE'></tfoot>
        <legend id='qMTTE'><style id='qMTTE'><dir id='qMTTE'><q id='qMTTE'></q></dir></style></legend>

      2. C#“等待"从桌面应用程序使用 WinRT 时出错

        时间:2023-09-17
        <i id='pLcsD'><tr id='pLcsD'><dt id='pLcsD'><q id='pLcsD'><span id='pLcsD'><b id='pLcsD'><form id='pLcsD'><ins id='pLcsD'></ins><ul id='pLcsD'></ul><sub id='pLcsD'></sub></form><legend id='pLcsD'></legend><bdo id='pLcsD'><pre id='pLcsD'><center id='pLcsD'></center></pre></bdo></b><th id='pLcsD'></th></span></q></dt></tr></i><div id='pLcsD'><tfoot id='pLcsD'></tfoot><dl id='pLcsD'><fieldset id='pLcsD'></fieldset></dl></div>
        <legend id='pLcsD'><style id='pLcsD'><dir id='pLcsD'><q id='pLcsD'></q></dir></style></legend>

          • <bdo id='pLcsD'></bdo><ul id='pLcsD'></ul>

                <tbody id='pLcsD'></tbody>

            • <small id='pLcsD'></small><noframes id='pLcsD'>

                  <tfoot id='pLcsD'></tfoot>
                  本文介绍了C#“等待"从桌面应用程序使用 WinRT 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我尝试使用 C# 中的 Windows 运行时从桌面应用获取我的 GPS 位置.

                  I trying to get my GPS position from a Desktop app, using Windows Runtime, in C#.

                  我按照 这个方法 进行设置使用 Visual Studio 和 此代码示例 创建以下内容作为 C# 控制台应用程序的简单代码:

                  I followed this how-to to set up Visual Studio and this code sample to create the following trivial code as a C# console app :

                  using System;
                  using System.Collections.Generic;
                  using System.Linq;
                  using System.Text;
                  using System.Threading;
                  using System.Threading.Tasks;
                  
                  using System.IO;
                  using System.Runtime;
                  using System.Windows;
                  
                  using Windows;
                  using Windows.Devices.Geolocation;
                  using Windows.Foundation;
                  using Windows.Foundation.Collections;
                  
                  namespace GeoLocCS
                  {
                      public sealed partial class Program
                      {
                          static void Main(string[] args)
                          {
                              Test test = new Test();
                              Console.Read(); 
                          }
                      }
                  
                      public class Test
                      {
                          private Geolocator geolocator;
                  
                          public Test()
                          {
                              Console.WriteLine("test");
                              geolocator = new Geolocator();
                  
                              this.getPos();
                          }
                  
                          async void getPos()
                          {
                              Geoposition pos = await geolocator.GetGeopositionAsync();
                              Console.WriteLine(pos.Coordinate.Latitude.ToString());
                          }
                      }
                  }
                  

                  尝试编译时出现错误:

                  Error 1 'await' requires that the type 'Windows.Foundation.IAsyncOperation<Windows.Devices.Geolocation.Geoposition>' have a suitable GetAwaiter method. Are you missing a using directive for 'System'?
                  

                  我尝试引用每个可以引用的 DLL,例如System.runtime"、System.Runtime.WindowsRuntime"、Windows.Foundation"...

                  I tried to reference every DLL that I could, like "System.runtime", "System.Runtime.WindowsRuntime", "Windows.Foundation"...

                  我错过了什么?

                  谢谢你的回答,

                  谢尔盖

                  推荐答案

                  我终于找到了我的问题:

                  I finally figured out my problem :

                  • 我使用的是 8.1,所以我在 .csproj 文件 (targetingPlatform) 中更改了这个,而不是针对 8.0
                  • 修改后,我可以引用Windows"
                  • 我手动引用了以下两个 DLL:

                  • I am on 8.1 so I changed this in the .csproj file (targetingPlatform) instead of targeting 8.0
                  • After that modification, I could reference "Windows"
                  • I manually referenced the two following DLLs :

                  C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Runtime.dll

                  C:WindowsMicrosoft.NETFramework64v4.0.30319System.Runtime.WindowsRuntime.dll

                  这篇关于C#“等待"从桌面应用程序使用 WinRT 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:哪个 DLL 具有 Windows.Devices.Gelocation 命名空间? 下一篇:T-Sql 中的时间戳在 C# 中是什么意思?

                  相关文章

                  <i id='ms2hm'><tr id='ms2hm'><dt id='ms2hm'><q id='ms2hm'><span id='ms2hm'><b id='ms2hm'><form id='ms2hm'><ins id='ms2hm'></ins><ul id='ms2hm'></ul><sub id='ms2hm'></sub></form><legend id='ms2hm'></legend><bdo id='ms2hm'><pre id='ms2hm'><center id='ms2hm'></center></pre></bdo></b><th id='ms2hm'></th></span></q></dt></tr></i><div id='ms2hm'><tfoot id='ms2hm'></tfoot><dl id='ms2hm'><fieldset id='ms2hm'></fieldset></dl></div>
                1. <tfoot id='ms2hm'></tfoot>

                  <small id='ms2hm'></small><noframes id='ms2hm'>

                      <bdo id='ms2hm'></bdo><ul id='ms2hm'></ul>
                    1. <legend id='ms2hm'><style id='ms2hm'><dir id='ms2hm'><q id='ms2hm'></q></dir></style></legend>