当前位置: 动力学知识库 > 问答 > 编程问答 >

windows phone 8.1 - background service is killing app when bluetooth changes state

问题描述:

I am trying to write a BLE wp 8.1 application which should reconnect to

a BLE device when the device is in range. The problem is that when I'm

trying to modify the connection state the application crashes.

My starting point is :

http://code.msdn.microsoft.com/windowsapps/Keep-The-Keys-Bluetooth-LE-6d4e6d47

I cannot attach the debugger to see if the Run method was called in the background service,

because the application crashes.

I'm stuck in this problem, any help would be appreciated, thanks

Update:

Setting a try and catch method just after the register method for a background task shows me this :

An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module.

网友答案:

[SOLVED] Thanks to http://visualstudiomagazine.com/articles/2013/05/01/background-tasks-in-windows-store-apps.aspx

where it says clearly that :

it is extremely important to add a reference to the new project from your app, because the main app never actually calls the background task directly. A compile-time error won't be generated without a reference, but your app will crash once the trigger is fired. To add the reference to your app, right-click on the References folder under the BackgroundTaskDemo project in the Solutions Explorer and select Add Reference. In the left column, under Solution, select Projects. Check the BackgroundTasks project and select OK.

分享给朋友:
您可能感兴趣的文章:
随机阅读: