We might end up with the above exception while developing your window phone application development, basically on the location services enabled application development. To resolve this issue you need to follow the below steps, the exception is because of the application settings on the capabilities. This issue might be common across different other capability as well, so you need to activate the capability which we are planning to use it in our application development. [more]
Exception:
An exception of type 'System.UnauthorizedAccessException' occurred in System.Device.ni.dll but was not handled in user code

Solution:
Open Visual Studio 2012 IDE and navigate to the project where the issue exists, now open the WMAppManifest.xml file under the properties section.

Go to the Capabilities section and select the appropriate capability, in our case we need to select ID_CAP_LOCATION from the list of available capabilities.

Save the project and build and execute the application to run in the emulator which will solve the issue. Hope this tip will be helpful for you and can be used in other capability fix as well.