Unity 3d Unhandled Exception: System.UnauthorizedAccessException

I am new to Unity. I am getting this error from time to time in Unity ever since I am using it. It says : Unhandled Exception: System.UnauthorizedAccessException: Access to the path “C:\Users\MyPC\Desktop\Folder\ProjectName\Temp\Assembly-CSharp.dll.mdb” is denied

I tried googling, but to no success. I do not get this error on my office PC.

I am using Windows 8 laptop. Have Avira antivirus installed. Unity version is 5. Android sdk version is 2.2. My project is located on a folder on the desktop.

Reimporting all assets did not help. Even restarting Unity does not stop the error. I have even tried uninstalling my antivirus(though that’s a risk), but no use. Also tried running Unity as administrator, but did not help.

I usually see this when I’m using Visual Studio with Unity. In some cases it opens temp files, which Unity tries to change. In my case it never was a problem. Closing VS and going back to Unity fixes it.

Maybe you have some other program that occupies your file. Possibly MonoDevelop, so maybe try to close it until Unity is done managing temp files.

Just for some general info: the error will most like mean that the file is being used by another program at the same time that Unity is trying to write to it. At least I can’t think of any reason for Unity not to have access to its own files.