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

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:

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

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

1 Like

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

[SOLVED]: To solve close Unity and VS, then I’ve just deleted these 2 files: 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;

11 Likes

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

donde encuentro entos documentos
DDCE

THANK YOU FOR THE FIX!!! I THOUGHT MY PROJECT WAS GONE

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://discussions.unity.com/t/736093/3

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://discussions.unity.com/t/807568/3

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

https://discussions.unity.com/t/826718/2

Share/Sharing source code between projects:

https://discussions.unity.com/t/719810/2

Setting up an appropriate .gitignore file for Unity3D:

https://discussions.unity.com/t/834885/5

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

2 Likes

library/scriptassemblies/assembly-csharp.dll

1 Like