首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows电话崩溃device.Sensors.ni.dll

Windows电话崩溃device.Sensors.ni.dll
EN

Stack Overflow用户
提问于 2015-04-17 10:48:54
回答 1查看 104关注 0票数 0

我在我的应用程序上经历了一些崩溃(有点像指南针应用程序)。windows崩溃报告告诉我:

代码语言:javascript
复制
frame 0: 
Microsoft.Devices.Sensors.ni.dll; Microsoft.Devices.Sensors.Accelerometer.Start; 0x0000006c    
frame 1:
PivotApp1.ni.DLL; PivotApp1.MainPage+_start_d__0.MoveNext; 0x000001d4    
frame 2: 
mscorlib.ni.dll; System.Runtime.CompilerServices.AsyncMethodBuilderCore._ThrowAsync_b__3; 0x00000036

我无法理解这到底意味着什么。根据我从它得到的,可能是因为加速度计。

这是我当前的代码,似乎错误是从这里的某个地方生成的:

代码语言:javascript
复制
private async void start()
    {
        //Check for the user agreement in use his position. If not, method returns.
        if ((bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"] != true)
        {
            // The user has opted out of Location.

            MessageBox.Show(AppResources.main_cantuse);

            Application.Current.Terminate();
        }

        else
        {
            //KOMPASS
            if (compass == null)
            {
                // Instantiate the compass.
                compass = new Compass();

                // Specify the desired time between updates. The sensor accepts
                // intervals in multiples of 20 ms.
                compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);

                compass.CurrentValueChanged +=
                new EventHandler<SensorReadingEventArgs<CompassReading>>(compass_CurrentValueChanged);
                compass.Calibrate +=
                new EventHandler<CalibrationEventArgs>(compass_Calibrate);
            }

            try
            {
                compass.Start();
                timer.Start();

                accelerometer = new Accelerometer();
                accelerometer.CurrentValueChanged +=
                    new EventHandler<SensorReadingEventArgs<AccelerometerReading>>(accelerometer_CurrentValueChanged);
                accelerometer.Start();
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(AppResources.main_unabletostart);                    
            }

我想问一问,我是否必须检查加速度计是否已经准备好(或空检查或其他什么)?

如有任何帮助或指导,我们将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-17 19:49:41

这些崩溃可能是由没有指南针的设备造成的(是的,有这样的设备)。

您应该用Compass.IsSupported检查指南针,只有当它返回true时才使用它。

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

https://stackoverflow.com/questions/29697142

复制
相关文章

相似问题

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