I have an issue on Unity 2018.2.14 (Windows 10 x64), updating from Unity 5.5.0p4 (Android, IL2CPP, .NET 4.x).
InvalidOperationException: Sequence contains no matching element
at System.Linq.Enumerable.Single[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00070] in <839a3cb835c04d14aeb58d83bb7bc4bd>:0
at UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CompileScripts (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, UnityEditor.BuildTargetGroup platformGroup, UnityEditor.BuildTarget platform) [0x00054] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\EditorCompilation.cs:759
at UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface+<CompileScripts>c__AnonStorey2.<>m__0 () [0x00017] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\EditorCompilationInterface.cs:212
at UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface.EmitExceptionAsError[T] (System.Func`1[TResult] func, T returnValue) [0x00003] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\EditorCompilationInterface.cs:85
Looks definitely like an error somewhere in Editor\Mono\Scripting\ScriptCompilation\EditorCompilation.cs:759
VCS link from log file: Built from '2018.2/release' branch; Version is '2018.2.14f1 (3262fb3b0716) revision 3302139'; Using compiler version '191225831'
Most likely it is. Looks like a bug to me. Please file an issue and weāll take a look (most likely it is a bug related to the compilation pipeline /cc @lukaszunity )
I cannot narrow down repro; project contains over 4000 cs-files. But similar bug reproduces in 2017.4.15 too (Iām trying different versions of Unity), slightly different trace this time:
InvalidOperationException: Operation is not valid due to the current state of the object
at System.Linq.Enumerable.Single[CustomScriptAssembly] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Single[CustomScriptAssembly] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
at UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CompileScripts (EditorScriptCompilationOptions options, BuildTargetGroup platformGroup, BuildTarget platform) [0x00054] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\EditorCompilation.cs:589
at UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface+<CompileScripts>c__AnonStorey2.<>m__0 () [0x00017] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\EditorCompilationInterface.cs:177
at UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface.EmitExceptionAsError[Boolean] (System.Func`1 func, Boolean returnValue) [0x00003] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\EditorCompilationInterface.cs:75
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:LogException(Exception) (at C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\EditorCompilationInterface.cs:55)
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:EmitExceptionAsError(Func`1, Boolean) (at C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\EditorCompilationInterface.cs:79)
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:CompileScripts(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget) (at C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\EditorCompilationInterface.cs:177)
I will try to attach log file (150 KLoC)⦠Failed: āThe uploaded file is too large.ā Maybe zipped will fit?
What does EditorCompilation.cs do in method CompileScripts() on line 759 of changeset (65e0713a5949) revision 6676593 of 2018.2/staging branch? Why does it call .Single() assuming there is exactly one such element?
The same in ā2018.2.16f1 (39a4ac3d51f6) revision 3777708ā. All game objects in scene display āThe associated script cannot be loadedā, and Editor reports internal incorrect use of System.Linq.Enumerable.Single.
Could you please at least replace .Single() call with .FirstOrDefault() + null-check?
Please guys, donāt make me feel abandoned in hopeless despair, alone with hostile environment of Unity.
(Maybe I just should patch UnityEditor.dll with Reflector or smth, I donāt know. Looks pretty complicated, and Iām not sure if it is not protected with fingerprints/check sums, at least it is not strong-named.)
We need to know which state lead to the issue, so we can reproduce it in a test and fix it permanently.
Could you perhaps strip down the project and from there create a smaller test project where the issues reproduces, but does not have any of your NDA code? It looks like it is the setup of scripts and possibly some editor extensions that is causing the issue and not the contents of the scripts themselves.
Looks like there are some usual issues in source code (obsolete API calls or something like that), but some bug in Unity prevents it from printing actual errors. Visual Studio also doesnāt report any errors.
Even if I introduce intentional error like #error Test error. Unity doesnāt print this error in Console, just its ā
ArgumentNullException: Argument cannot be null.ā