相关疑难解决方法(0)

应用程序在调试时不会崩溃,但在正常运行时会出现问题

系统信息

  • Windows 10技术预览版(内部版本9926)
  • Visual Studio Community 2013

    尝试调试:
  • [AT&T] Lumia 635(Windows 10技术预览版手机内置9941瓦特/ Lumia Cyan)
  • [AT&T] Lumia 1520(带有Lumia Denim和PfD的Windows Phone 8.1)
  • [Unlocked] BLU Win Jr(Windows Phone 8.1 with PfD)
  • [Verizon] Lumia Icon(带有Lumia Denim和PfD的Windows Phone 8.1)

我试图在我的应用程序中使用位置服务.以前,我有Visual Studio抛出错误.这是一个ArgumentException带有消息" Use of undefined keyword value 1 for event TaskScheduled in async".谷歌搜索没有找到任何解决方案.

这是代码:

Geolocator Locator = new Geolocator();
Geoposition Position = await Locator.GetGeopositionAsync();
Geocoordinate Coordinate = Position.Coordinate;
Run Code Online (Sandbox Code Playgroud)

当我可以得到抛出的错误时,在上面的示例中的第2行或第3行抛出了异常.我简化了原始代码以尝试修复它,但这是原始代码:

Geolocator Locator = new Geolocator();
Geocoordinate Coordinate = (await Locator.GetGeopositionAsync()).Position.Coordinate;
Run Code Online (Sandbox Code Playgroud)

整个应用程序在调试时可以正常工作,但几乎瞬间崩溃.

这是一个Windows 8.1 Universal项目,专注于手机项目. …

c# geolocation argumentexception async-await win-universal-app

5
推荐指数
1
解决办法
1574
查看次数

如何在通用应用程序中禁用任务并行库的 ETW 事件源?

任务并行库使用Windows 事件跟踪 (ETW)进行日志记录。显然,在 Windows Phone 或 Windows Store .NET Runtime 下,存在与 TPL 或 ETW 中的日志记录相关的错误。原始问题描述为here

一种可能的解决方法是禁用 TPL 的 ETW EventSource

如果我真的想要,如何从通用 Windows 应用程序中禁用它

反射适用于桌面应用程序,但不适用于 WP/WinRT 应用程序。EventCommand.Disable不被识别为有效命令EventSource.SendCommand(尽管它在 ETW 内部使用)。这是要使用的代码(作为控制台应用程序):

using System;
using System.Threading.Tasks;
using System.Diagnostics.Tracing;
using System.Reflection;

namespace ConsoleApplication
{
    class Program
    {
        internal class MyEventListener : EventListener
        {
            protected override void OnEventSourceCreated(EventSource eventSource)
            {
                Console.WriteLine(eventSource);
                base.OnEventSourceCreated(eventSource);
                if (eventSource.Name == "System.Threading.Tasks.TplEventSource")
                {
                    Console.WriteLine("enabled: " + eventSource.IsEnabled());

                    // trying to disable …
Run Code Online (Sandbox Code Playgroud)

.net c# logging task-parallel-library win-universal-app

5
推荐指数
1
解决办法
966
查看次数