- Home /
System.UnauthorizedAccessException when deploying to Windows Phone 8
I am almost head-desking over this problem. Here's the deal: I'm trying to build stuff for my Windows Phone 8. I downloaded the SDK, make a small Unity project with just a GUIText and deployed it. Magically, it worked! So awesome! So I decided to add a sphere that moves. Built, deployed, boom! Worked again! I then tried to add back-button support with code like so (in C#, btw):
bool backPressed = false;
void Update()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
if(backPressed)
{
Application.Quit();
}
else
{
guiText.text = "You pressed the back button! Press again to exit game.";
backPressed = true;
}
}
}
I went to deploy, and I got this error:
{ a bunch of stuff with serial numbers and whatnot that I'm not going to put on the internet }
[13:54:14.233] Deleting app icon.
[13:54:14.264] System.UnauthorizedAccessException: Access is denied.
at Microsoft.VisualStudio.DeviceConnectivity.Interop.ConManServerClass.InstallApplication(String in_pProductId, String in_pInstanceId, String in_bstrApplicationGenre, String in_bstrAppIconPath, String in_bstrXapPath)
at Microsoft.SmartDevice.Connectivity.Device.InstallApplication(Guid productId, Guid instanceId, String applicationGenre, String iconPath, String xapPackage)
at Microsoft.SmartDevice.Connectivity.Wrapper.DeviceObject.InstallApplication(Guid productId, Guid instanceId, String applicationGenre, String iconPath, String xapPackage)
at Unity.Program.Run(Guid appId, String iconPath, String xapPath, Boolean test)
at Unity.Program.Run(String xapPath, Boolean test)
at Unity.Program.Main(String[] args)
[13:54:14.264] Exiting Windows Phone 8 Runner.
What the dang?! I tried a bunch of stuff to fix it, starting with just trying again - that didn't work. I commented out the code I just added - nope. I deleted the generated VS2012 solution and rebuilt it - that didn't work either. I unregistered and then reregistered my phone, but to no avail. I disconnected and reconnected my phone. I closed and reopened Unity. I even went so far as to unregister my phone, unplug it, shut down my computer, turn it back on (not using the 'Restart' action - literally 'Shut Down'ing) reconnect and reregister my phone, and restart Unity. Nothin'. Same dang error.
What's going on? How can I fix this strange problem?
Update:
Just built the app detailed here. It deploys fine, but the Unity app still does not.
Answer by Gidaio · Sep 23, 2013 at 12:59 AM
I think I figured it out, and if I'm right, it's entirely my fault.
I deployed this before I had actually made a way to exit the game via the back button. I think (think) what happened is that I hackishly closed it without actually ending the process. When Unity went to overwrite it with the new version, the process was still running, and you can't overwrite a running file. Turning my phone off and then on again solved this issue, which is what leads me to believe this.
Your answer
![](https://koobas.hobune.stream/wayback/20220613114627im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
UWP Deployment Error :: DEP0001 : Unexpected Error: -2146958844 2 Answers
Android not working 1 Answer
Deployment to android 1 Answer
Combining 3 Games into a single APK 1 Answer
Is there a way to optimize Input.GetAxis on windows phone? 1 Answer