Search Unity

Resolved Scripts not working in Unity (Loading assembly failed) [CHECK LAST REPLY]

Discussion in 'Scripting' started by SirioRigel, Oct 1, 2021.

  1. SirioRigel

    SirioRigel

    Joined:
    Apr 10, 2021
    Posts:
    27
    So here's the problem, my script worked perfectly when I launched Unity and I even played my game and tested it for 5 minutes, after that I wanted to add a new feature and I found out that an error message appeared which wiped all the scrips from their assigned objects in the inspector:
    Code (CSharp):
    1. Loading assembly failed: "Library/ScriptAssemblies/Assembly-CSharp.dll" reason: File does not contain a valid CIL image
    What does this mean and how do I fix it, because I cannot add or modify any scripts at the moment and I'm freaking out looking for a solution;
    When I try to add back the scripts to the inspector it says that the class and the name of the scripts have to match which they do, and that I have to check if I have the monobehaviour class which all of them do.
    Help me please I have tryed everything but nothing seemed to work
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    That's a weird one. Try restarting Unity, or failing that, trash the Library folder and reimport everything (make a backup copy before doing the second one, just in case).
     
  3. SirioRigel

    SirioRigel

    Joined:
    Apr 10, 2021
    Posts:
    27
    I have already tried restarting VS and Unity but no results.
    I have everything saved in a backup on Cloud, I'll try and let you know, if that backupped instance fails again I might have to reinstall Unity &/or VS 2019
     
  4. SirioRigel

    SirioRigel

    Joined:
    Apr 10, 2021
    Posts:
    27
    [SOLVED]: To solve close Unity and VS, then I've just deleted these 2 files:
    Code (CSharp):
    1. Assembly-CSharp.dll ; Assembly-CSharp.pdb
    I think that probably they were both corrupted. After deleting them, I booted Unity and VS and everything worked fine;
     
  5. zedz

    zedz

    Joined:
    Aug 31, 2013
    Posts:
    250
    Yeah just have this now, I think its revenge cause I was swearing at unity and then the PC crashed

    edit: & yes the answer was to delete these 2 files,
    Assembly-CSharp.dll ; Assembly-CSharp.pdb
    So I assume corrupt files which stop unity from actually doing anything when pressing play
     
    Last edited: Feb 3, 2023
  6. Morgaer

    Morgaer

    Joined:
    Oct 11, 2022
    Posts:
    1
    donde encuentro entos documentos
    DDCE
     
  7. CherryBunn

    CherryBunn

    Joined:
    May 13, 2023
    Posts:
    1
    THANK YOU FOR THE FIX!!!!!! I THOUGHT MY PROJECT WAS GONE
     
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    Please don't live like this. It is 2023, nobody should have to live like this.

    Move up the foodchain... evolve, grow, make your project immortal.

    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:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    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:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    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):

    https://thoughtbot.com/blog/how-to-git-with-unity

    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.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
     
    Bunny83 likes this.
  9. kegcheck

    kegcheck

    Joined:
    May 22, 2020
    Posts:
    1
    library/scriptassemblies/assembly-csharp.dll