Windows 10, VS 2015, can not start debugging the WindowsPhone 8.0 application on the emulator / device


I have a fresh Windows 10 install, fresh VS2015 install.

Windows 8.1 emulators are installed, they startup as expected and they can see the internet. So far so good.

Compiling and deploying the Windows Phone 8.0 (silverlight) application works fine, however, debugging refuses to start with the message:

Status bar: Launching TaskHost.exe failed. Popup: The application could not be launched for debugging. Ensure that the target device screen is unlocked and that the application is installed.

I have checked (the obvious) and the device\emulator is unlocked and I can physically run the app that was deployed when the debugging session was attempted - so I know its installed. Confirmed by uninstalling and re-deploying.

The same error occurs with the emulator AND the device. I can debug normal (non windows phone) applications just fine.

Output logs:

2>------ Deploy started: Project: {APPNAME}.WinPhone, Configuration: Debug x86 ------
2>Deploying F:\TFS\{PATH}\x86\Debug\{APPNAME}.WinPhone_Debug_x86.xap...
2>Connecting to Emulator 8.1 WVGA 4 inch 512MB...
2>The application is already installed on the device. Checking if an incremental deployment is possible...
2>Doing incremental deployment...
2>Updating information related to modified files...
2>Deployment of F:\TFS\{PATH}\x86\Debug\{APPNAME}.WinPhone_Debug_x86.xap succeeded.
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

Any ideas?

You need to set the following in your code:

// Avoid screen locks while debugging.
if (System.Diagnostics.Debugger.IsAttached)
    PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;