Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Copying assembly from 'Temp/Assembly-CSharp.dll' to 'Library/ScriptAssemblies/Assembly-CSharp.dll' f

Discussion in 'Editor & General Support' started by Fantom4U, Nov 13, 2019.

  1. Fantom4U

    Fantom4U

    Joined:
    Oct 5, 2019
    Posts:
    1
    Hi, i'm struggling with this bug all day, I'm on version 2019.2.12f1 of the editor:
    When I open up a new project and add a new C# script in the project tab (Right click->Create->C# Script),
    I suddenly get an error on the console window which prevents me from entering playmode:

    "Copying assembly from 'Temp/Assembly-CSharp.dll' to 'Library/ScriptAssemblies/Assembly-CSharp.dll' failed".

    Sometimes I get several errors of this kind (Copying assembly from 'temp/x.dll' to 'Library/ScriptAssemblies/x.dll' failed), sometimes I get only 1.

    I have done nothing in the project but add a single script and haven't touched any of the code inside it.

    I have already searched in google for the answer and the answers are usually:
    1. 'reimport your script' (did that, didn't work).
    2. 'check if there is an antivirus that interferes with the scripts' (I have none installed).
    3. 'delete all files from the temp folder and restart the project' (tried, didn't work).

    What can I do?
     
  2. paulrnc

    paulrnc

    Joined:
    Sep 2, 2017
    Posts:
    1
    Watching thread for the solution, I've also tried upgrading and downgrading Unity but did not work as well.
     
  3. cristianm_unity

    cristianm_unity

    Unity Technologies

    Joined:
    Oct 16, 2018
    Posts:
    234
    Hi! It should be something external to Unity blocking the copy operation from the Temp folder to the Library folder.

    That could happen, for instance, if you don't have enough space in your disk or if there is another process using that files/folder (usually an antivirus).

    So I would suggest to use a tool to check what process could be using the 'Library/ScriptAssemblies/x.dll' file (you could start here: https://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows).

    Also, you mentioned you deleted the Temp folder, but actually, it's more likely that the problem is in the destination folder, which is the Library folder, have you tried deleting the Library folder?

    Please take into account that deleting the Library folder, will cause the entire project to be reimported.

    And finally, be careful when touching directly those folders and files, make sure first you have somewhere a copy of your project.
     
  4. WeirdBeardDev

    WeirdBeardDev

    Joined:
    Feb 16, 2013
    Posts:
    14
    Is there a way to force Unity to try and copy again? Right now I have to edit a script to induce an error (generally I remove a semi-colon), switch back to Unity to get it to recompile/copy again, then back to the script to fix my error, and then back to Unity for recompile/copy. It mostly works, but it's tedious.
     
  5. cristianm_unity

    cristianm_unity

    Unity Technologies

    Joined:
    Oct 16, 2018
    Posts:
    234
    Hey @WeirdBeardDev,

    If I understand correctly, right click on the script and reimport should work.
     
  6. WeirdBeardDev

    WeirdBeardDev

    Joined:
    Feb 16, 2013
    Posts:
    14
    If I reimport a script (any script) will that make Unity attempt to copy the assembly 'Temp/Assembly-CSharp.dll' again?
     
  7. cristianm_unity

    cristianm_unity

    Unity Technologies

    Joined:
    Oct 16, 2018
    Posts:
    234
    It should be any script in the Assembly-CSharp, or in other words, any script in your project that is not part of an Assembly Definition.

    I have just checked it and it works for me, the Assembly-CSharp.dll file gets updated, that is because reimporting a script will recompile it and then update the Assembly.
     
  8. WeirdBeardDev

    WeirdBeardDev

    Joined:
    Feb 16, 2013
    Posts:
    14
    I had it happen like a dozen times yesterday, and a few times before I originally posted and now nothing. I'll report back once I encounter it again.
     
  9. WeirdBeardDev

    WeirdBeardDev

    Joined:
    Feb 16, 2013
    Posts:
    14
    I knew as soon as I posted that it would happen again. Sure enough, I reimported a random script and it worked. That saves me a ton of time. Thanks!
     
    cristianm_unity likes this.
  10. mavener

    mavener

    Joined:
    May 23, 2020
    Posts:
    2
    Don't know if this helsp, but for me the culprit was Dropbox. I had my Unity project in a Dropbox folder and was getting those errors all the time. Probably Dropbox indexing the files etc... After moving it to a different folder, everything works fine.
     
    WeirdBeardDev likes this.
  11. WeirdBeardDev

    WeirdBeardDev

    Joined:
    Feb 16, 2013
    Posts:
    14
    Ultimately that's what I did as well. Since I moved my project out of Dropbox I've had no issues.
     
  12. Kay_NLR

    Kay_NLR

    Joined:
    Feb 19, 2020
    Posts:
    2
    We had problems with this issue and we expect it to be caused by a Windows group policy, since all computers in the company have the same problem.

    Here is what we found that can highly reduce the frequency of the problem:
    - Change setting to “Edit/Preferences/General/Script Changes While Playing” : “ Stop Playing And Recompile”
    - Use a Unity version 2020 and up
    - Upgrade laptops, that where are not intended for Unity development / lack in performance (I don't know what bottleneck(s) will affect the frequency of the problem).

    Hopefully this will reduce the frequency of the problem to almost 0. When it still happens, there is no need to restart Unity (like I first did...). What you can do is "right click/Refresh" on the folder (or script) with scripts that where changed.