Hey all, recently had this error pop up seemingly out of nowhere in my project (file paths edited for privacy):
error CS2012: Cannot open ‘C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\Bee\artifacts\1900b0aE.dag\Assembly-CSharp.dll’ for writing – ‘The requested operation cannot be performed on a file with a user-mapped section open. : ‘C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\Bee\artifacts\1900b0aE.dag\Assembly-CSharp.dll’’
I didn’t import anything new into my project, and this didn’t start after pulling a commit from the github repo. One minute I was editing and compiling scripts, the next this popped up. I was able to get things working again by restarting my computer, but the next time I compiled a script it popped right back up again.
I’ve tried re-importing and refreshing just about everything, even deleting my library folder, which didn’t work because Windows swears Assembly-CSharp.dll is being used by something. I have no idea what though, because according to Process Explorer its not being used anywhere.
I have no idea why this is happening and I can’t really work like this, so any help would be greatly appreciated.
Be sure you’re excluding that DLL from your source control. (See below)
Otherwise maybe you have some antivirus attempting to lock and study that DLL and preventing Unity from rewriting it.
PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL
I’m sorry you’ve had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.
Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).
You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.
As far as configuring Unity to play nice with git, keep this in mind:
I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.
Here is how I use git in one of my games, Jetpack Kurt:
Using fine-grained source control as you work to refine your engineering:
Share/Sharing source code between projects:
Setting up an appropriate .gitignore file for Unity3D:
Generally the ONLY folders you should ever source control are:
Assets/
ProjectSettings/
Packages/
NEVER source control Library/ or Temp/ or Logs/
NEVER source control anything from Visual Studio (.vs, .csproj, none of that noise)
Setting git up with Unity (includes above .gitignore concepts):
It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It’s simply ridiculous not to back up.
If you plan on joining the software industry, you will be required and expected to know how to use source control.
Source control does require learning, but there are TONS of tutorials and courses and online reference.
You should strive to use source control as confidently as you use your file/folder system.
“Use source control or you will be really sad sooner or later.” - StarManta on the Unity3D forum boards
Thanks for the response! I double checked the repo, and the Assets, Project Settings, and Packages are the only folders tracked by source control. There is a .vsconfig in there, but its always been there and I’m pretty sure its auto generated.
Wise of my antivirus, I haven’t changed anything on my end, but that seems to be the most logical conclusion. Something takes over the entire Library file as soon as I try and compile a script. I tried rebooting my PC, deleting library since I have access until I compile something, and re-generating it. That still hasn’t helped the problem, the same error shows up every time. I tested one of my other projects, and it complies just fine, so it seems to be exclusive to this one project.
I also got this error last time, which might provide some more info:
Failed to find entry-points:
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: ‘Assembly-CSharp-Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ —> System.Exception: Failed to resolve assembly ‘Assembly-CSharp-Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ in directories: C:\Program Files\Unity\Hub\Editor\2022.3.11f1\Editor\Data\MonoBleedingEdge\lib\mono\unityjit-win32
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.burst@1.8.9
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.burst@1.8.9\Unity.Burst.CodeGen
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.visualscripting@1.9.1\Editor\VisualScripting.Core\Dependencies\DotNetZip
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.ext.nunit@1.0.6\net35\unity-custom
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.visualscripting@1.9.1\Editor\VisualScripting.Core\EditorAssetResources
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.collections@1.2.4\Unity.Collections.LowLevel.ILSupport
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.collab-proxy@2.2.0\Lib\Editor\PlasticSCM
C:\Program Files\Unity\Hub\Editor\2022.3.11f1\Editor\Data\Managed
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.ide.rider@3.0.25\Rider\Editor
C:\Program Files\Unity\Hub\Editor\2022.3.11f1\Editor\Data\PlaybackEngines\WindowsStandaloneSupport
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.visualscripting@1.9.1\Runtime\VisualScripting.Flow\Dependencies\NCalc
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\PackageCache\com.unity.visualscripting@1.9.1\Editor\VisualScripting.Core\Dependencies\YamlDotNet
C:\Program Files\Unity\Hub\Editor\2022.3.11f1\Editor\Data\Managed\UnityEngine
C:\Users\username\Documents\GitHub\project-ubiquitous-umbrella\UbiquitousUmbrella\Library\ScriptAssemblies —> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: ‘Assembly-CSharp-Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’
at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in <853812ae52c341daaef3c62ecdb86b32>:0
at zzzUnity.Burst.CodeGen.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00013] in <772865cdae2d4bff9c305a06338cabcf>:0
— End of inner exception stack trace —
at zzzUnity.Burst.CodeGen.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00060] in <772865cdae2d4bff9c305a06338cabcf>:0
at Burst.Compiler.IL.AssemblyLoader.Resolve (Mono.Cecil.AssemblyNameReference name) [0x0007e] in <772865cdae2d4bff9c305a06338cabcf>:0
at Burst.Compiler.IL.Server.EntryPointMethodFinder.FindEntryPoints (System.String[ ] rootAssemblyNames, Burst.Compiler.IL.Hashing.CacheRuntime.HashCacheAssemblyStore assemblyStore, Burst.Compiler.IL.AssemblyLoader assemblyLoader, Burst.Compiler.IL.NativeCompilerOptions options, Burst.Compiler.IL.Server.ProfileDelegate profileCallback, System.Boolean includeRootAssemblyReferences, System.Boolean splitTargets) [0x00055] in <772865cdae2d4bff9c305a06338cabcf>:0
at Burst.Compiler.IL.Server.CompilerServer+<>c__DisplayClass18_1.b__0 (Burst.Compiler.IL.Server.Caching.CacheManager cacheManager) [0x0005e] in <772865cdae2d4bff9c305a06338cabcf>:0
at Burst.Compiler.IL.Server.CompilerServer+<>c__DisplayClass26_01[TResult].<RunTask>b__0 () [0x00145] in <772865cdae2d4bff9c305a06338cabcf>:0 at Burst.Compiler.IL.Server.CompilerServer.RunTask[TResult] (Burst.Compiler.IL.Server.TargetKey target, System.String taskName, System.String[ ] assemblyFolders, System.Threading.CancellationToken cancellationToken, System.Func2[T,TResult] function) [0x00131] in <772865cdae2d4bff9c305a06338cabcf>:0
at Burst.Compiler.IL.Server.CompilerServer.FindMethods (Burst.Compiler.IL.Server.CompilerServerOptions options, Burst.Compiler.IL.Aot.AotCompilerOptions aotOptions, Burst.Compiler.IL.Server.TargetKey target, Burst.Compiler.IL.Server.Caching.CacheManager cacheManager, Burst.Compiler.IL.CompilerStatistics stats, System.Threading.CancellationToken cancellationToken) [0x00299] in <772865cdae2d4bff9c305a06338cabcf>:0
at Burst.Compiler.IL.Server.CompilerServer+<>c__DisplayClass26_01[TResult].<RunTask>b__0 () [0x00145] in <772865cdae2d4bff9c305a06338cabcf>:0 at Burst.Compiler.IL.Server.CompilerServer.RunTask[TResult] (Burst.Compiler.IL.Server.TargetKey target, System.String taskName, System.String[ ] assemblyFolders, System.Threading.CancellationToken cancellationToken, System.Func2[T,TResult] function) [0x00131] in <772865cdae2d4bff9c305a06338cabcf>:0
at Burst.Compiler.IL.Server.CompilerServer.Compile (Burst.Compiler.IL.Server.CompilerServerOptions options, Burst.Compiler.IL.Server.CompilationMessageStreamer streamer, System.Threading.CancellationToken cancellationToken) [0x001af] in <772865cdae2d4bff9c305a06338cabcf>:0
Quick update: I’ve since completely nuked the project from my PC and pulled it fresh from GitHub. The same error still happens in the exact same way. Its only on this project, and everyone else working on the project has no issues on their respective ends. It only seems to happen when I open Visual Studio, edit a script, and then tab back to Unity after saving the script. The error always occurs at that specific recompile.
Well that’s kinda nutty… maybe cross check all the VS plugin crud??
Here’s my checklist:
This may help you with intellisense and possibly other Visual Studio integration problems:
Sometimes the fix is as simple as doing Assets → Open C# Project from Unity. Other times it requires more.
Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.
Also, try update the package inside of Unity: Window → Package Manager → Search for Visual Studio Editor → Press the Update button
Depending on flavor and version of Visual Studio, it may also have an installation step that you perform within the actual Visual Studio. This step seems finicky at best and may require multiple openings of VS before it comes up.
Update: The VSCode extension has been deprecated and abandoned:
Recently (July 2023) I worked on a Windows11 system that required a Microsoft component to be installed from within Visual Studio before it would work properly with all the OTHER software installed under Unity. I have no documentation on that process as I have only seen it once and it surprised me as well.
I just happened upon this, the same thing happened to me yesterday. My project suddenly decided not to work, gave me the same error, navigating to the same file. File wont delete, says its open elsewhere. Ive tried uninstalling/reinstalling both Unity and VS, and even a computer restore. Nothing works. Tried new projects, old versions, etc. Open a new one, create script, type literally “//wheeee” and get the same error, this time directing to the new projects path to the same file (assembly-csharp.dll)
Thats a good next step. I already tried checking that everything was up to date and working in the Package Manager, but I’ll check VS itself and report back. Your checklist mentioned the .vsconfig, which I’ve never messed with or given much thought to, would it be worth deleting it just to see if that helps?
As far as I can tell, no. Like I said above, this is only happening with this specific project. I had another project I was working on a couple of days ago that still works fine, I can compile scripts all day, same with a new project I made.
Man that really sucks, thankfully its only happening on one project for me. I’ll be sure to @ you if/when I find a solution!
Thanks, I appreciate it. My friend and I started a multiplayer game Jan 1st, it took a while but I finally set up a working server. today we were supposed to link projects and test it with friends, but I randomly got that error, and no nothing in any unity project will work. AND I cant find any helpful info online, its either not relevant or it doesnt lead anywhere…
Ive also tried using (i forget the name) but its like microsoft fire lock…? It finds apps that are in use, and where they are open. Tried to delete the file, said it was open. Searched that file. Not open. tried to delet again, said its open somewhere.
Likewise, if I (somehow) find a solution, ill try to put it here.
Ok, another update, I have found what seems to be the problem. Turns out it was my anti-virus, I use Webroot and it decided that every time I restart Unity and try to compile a script its going to lock down the Assembly-CSharp.dll. My work-around for this has been to completely kill the Webroot process (not just turn off protection, as I had before) while Unity is running. After that, I seem to have full access again and everything compiles just fine. I’ve used Webroot longer than I’ve been using Unity and never had a problem like this, so I can only imagine an update was pushed that is causing this. I’m going to look into how to allow Unity through any protections its put in place.
@Odyssean I’m not sure what anti-virus you use, but you might try what I did with yours and see if that helps as a short term fix.
@Kurt-Dekker Thanks a ton for the help and info (you linked some stuff on Unity and source control I’ve saved for future reference), but I’m 90% sure this is not a Unity related problem. Any further advice would be appreciated if you have it though.
@ZanOlsena hmm interesting. I have the same anti-virus (which cant be a coincidence), and ive disabled the 3 notches to the right and it still hasnt worked, but you mentioned killing the process completely. Dumb question but… how? Also, could you get it back? I would rather keep an anti-virus after all haha
Interesting, so Webroot must have done something then.
To shut it down completely, I had to right click the small task bar icon (under hidden icons, I’m spacing the proper name for those) and choose “shut down protection”. I did that with nothing open on my PC except Unity, just in case. After its shut down, I made a script edit to make sure it recompiled correctly, which it did, then searched up the Webroot executable and launched it again while Unity was still open. That let me recompile or do anything else I needed to until I closed the editor. Have to do the whole process the next time you launch it, but its a good temporary solution.
Haven’t had the chance to figure out how to tell Webroot to ignore it yet, but if I find one I’ll @ you again.
@ZanOlsena wow you werent kidding, that worked for me too. Huzzah! However, a temporary solution is not preferred (obviously).
I tried allocating that single file (Assembly-CSharp.dll) that started both our problems to be allowed through the advanced settings (in webroot its the PC security gear button, then Block/Allow Files, then Add File) but that didnt seem to do anything.
I also tried putting the Unity application itself as allowed, also did nothing.
I also thought about doing VS but couldnt find it as an application. I also may have incorrectly done the above ones, so you could try them as well if you feel the need. Were making progress!
@Odyssean I tried what you did as well, I think I allowed almost every file in my project through Webroot and it compiled ONCE before I got the error again. I even allowed Visual Studio through (the files and application are in Program Files (x86) for me) and that didn’t help. Oh well, the restart trick still seems to work.
I’m honestly out of ideas, I’ve reached out to Webroot through their support with a description of the issue just to see if I can get any response, but I get the feeling I’m in for a long wait and something about “adding it to the Block/Allow Files list” and a dismissive “try contacting Unity support” as if its somehow Unity’s problem.
Make sure your Antivirus has absolutely NOTHING to do with the contents of your project folder area. Don’t just add the DLL, exclude the entire project folder structure, all of it. This is software development, which regularly involves compiling fresh code, which to an AV solution might be flagged as nefarious shenanigans.
Also make sure you aren’t using anything line OneDrive or DropBox or DriveSync or whatever on this project. ALL types of drive sharing and mirroring software is explicitly NOT supported under Unity. Use proper source control.
I just added my entire Unity editor and project folders to my AV’s allowed list, and I got one compile in before it threw the same error again. And nope, not using any sort of drive sharing software, only GitHub.
Very interesting, I got a response from Webroot’s support which was basically “send us a log file”, which I’ve done, so I’ll report back what they tell me. Might be the AV isn’t the issue, but somehow resetting it fixes it for a short period?
I’m having this issue, and it’s going to ground any progress I could make until it’s resolved.
Hope for a quick fix!
Damn you Webroot :C
Edit:
Wait hol up… maybe I fixed it
I had my game stored in C:/Users/MYUSERNAME/Onedrive/Documents
It’s never been an issue until now but I moved everything out of the Onedrive folder and into the proper (or at least, non One-Drive version) of the Documents folder, and it looks like that might have squashed it. I also added the DLL to Webroot’s allowed scripts.
My game is now located at C:\Users/MYUSERNAME\Documents\
Edit 2:
Nevermind, got my hopes up for nothing…
It worked for a few minutes, until I created a script. Then it broke again.
My project was brand new and scriptless before this.