首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Microsoft Sensors.Windows示例异常

Microsoft Sensors.Windows示例异常
EN

Stack Overflow用户
提问于 2015-06-03 05:44:45
回答 1查看 314关注 0票数 1

当我试图在我的Windows10机器上运行Microsoft的Sensors.Windows示例项目(1.3.10417.1)时,我得到以下异常:

代码语言:javascript
复制
System.ArgumentException: Value does not fall within the expected range.
   at Windows.ApplicationModel.Store.CurrentApp.get_AppId()
   at Microsoft.Band.StoreApplicationPlatformProvider`2.GetApplicationIdAsync(CancellationToken token)
   at Microsoft.Band.BandClient.StartOrAwakeStreamingSubscriptionTasks()
   at Microsoft.Band.BandClient.SensorSubscribe(SubscriptionType type)
   at Microsoft.Band.Sensors.BandSensorBase`1.<>c__DisplayClass4.<StartReadingsAsync>b__3()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Band.Sensors.BandSensorBase`1.<StartReadingsAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at PunchingBand.Models.PunchingModel.<Connect>d__48.MoveNext()

看起来它抛出了异常,因为SDK使用的是CurrentApp,根据备注部分,这里 on CurrentAppSimulator是不可能的,如果应用程序不在Windows中列出的话。

如果SDK需要访问CurrentApp,那么在开发我的应用程序时,如何才能让它工作呢?在预编译的程序集中,我不可能将CurrentAppCurrentAppSimulator交换。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-05 05:16:01

更新:在Microsoft版本1.3.10702中修复了。如果可能的话,升级到该版本,否则使用下面的黑客。

在与.NET Reflector进行了一些调查之后,我想出了一个方法来让这件事发挥作用。只要在currentAppId上设置一个名为BandClient的私有字段,SDK就不会尝试从CurrentApp获取它。在建立到客户端的连接之后,在尝试流任何传感器之前,运行以下命令:

代码语言:javascript
复制
using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
{
    Type.GetType("Microsoft.Band.BandClient, Microsoft.Band")
        .GetRuntimeFields()
        .First(field => field.Name == "currentAppId")
        .SetValue(bandClient, Guid.NewGuid());

一定要包括对System.LinqSystem.Reflection的使用。这显然是一个非常麻烦的解决办法,因此希望它能在今后的Band发行版中得到解决。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30611731

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档