Can't create a new script without compiler errors....

I’m been working on a project for a few months , for the last 2 days , it won’t let me create a new script. When I do it says that I have compiler errors.

This is BEFORE I even do anything with the script. I just create the new script and give it a name and bam, compiler errors. Can someone please help me figure out what might be causing this and how to fix it?

This is the compiler error I get:

Unhandled Exception: System.UnauthorizedAccessException: Access to the path “C:\Users\Public\Documents\Unity Projects\New Unity Project 3\Temp\Assembly-CSharp.dll.mdb” is denied.

at System.IO.FileStream…ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in :0

at System.IO.FileStream…ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean isAsync, Boolean anonymous) [0x00000] in :0

at System.IO.FileStream…ctor (System.String path, FileMode mode, FileAccess access) [0x00000] in :0

at Mono.CompilerServices.SymbolWriter.MonoSymbolWriter.WriteSymbolFile (Guid guid) [0x00000] in :0

at Mono.CSharp.SymbolWriter+SymbolWriterImpl.WriteSymbolFile () [0x00000] in :0

at Mono.CSharp.SymbolWriter.WriteSymbolFile () [0x00000] in :0

at Mono.CSharp.CodeGen.Save (System.String name, Boolean saveDebugInfo, Mono.CSharp.Report Report) [0x00000] in :0

at Mono.CSharp.Driver.Compile () [0x00000] in :0

at Mono.CSharp.Driver.Main (System.String[ ] args) [0x00000] in :0

That’s not a compiler error in the common sense (meaning that your code fails to compile), but rather a compiler failure due to something other than your code being wrong. Looks like the compiler is trying to rebuild the symbol database for one of the compiled assemblies (probably after all code has been successfully compiled), but for some reason isn’t allowed by the file system and OS.

Try closing all instances of Unity and Visual Studio/MonoDevelop/whatever IDE you use, deleting the New Unity Project 3/Temp folder, and reopening the project. If you can’t delete the Temp folder, try closing all programs or even restarting your computer, then try again. Something is probably holding a lock on that file, preventing it from being rebuilt.

1 Like

Thanks for the response. The temp folder disappears when unity is closed, so I can’t delete it. I tried a restart ,but still nothing.

I think it may have to do with things disappearing from my “window” drop down menu up at the top of the editor.

I have programs/assets such as photon that need to be listed in that dropdown menu to work , but they keep removing themselves from it. I
I’ve tried deleting them and re-importing them but they still do not show up in the “window” drop down menu.

But then when they eventually do reappear in the dropdown menu after a day or 2, when I go to create a new script they disappear again. And this is before adding anything to or editing the new script.

I suspect the disappearing menu items are simply an effect of a failed compilation, rather than a cause.

Looking on Google for “unity Assembly-CSharp.dll.mdb access is denied” revealed some people who got around the problem by running Unity as administrator (not sure I recommend that, as it seems like a work-around to a different problem, but probably alright). Others had success disabling their anti-virus or white-listing Unity or the project folder so that the anti-virus program doesn’t try to lock and scan the files in the middle of Unity doing its thing.

2 Likes

that error seems more like an ACL or access rights issue… do you happen to have some kind of SVN like Perforce?

I would try closing Unity, open the directory with Windows Explorer and try checking the permission settings… also see if “read only” is enabled on the folder, if it is… uncheck it and apply changes to all subdirectories.