Error when booting project + when opening the first script

I am getting this error whenever I boot my project and again when I open the first script.

I am using unity 2019.4.10f1 and visual studio 2017

I can tell the error is because of my unity version + visual studio version, because when I install visual studio 2019 the error is fixed. But I don’t want to install visual studio 2019 I want to keep using 2017 because 2019 consumes a lot of my cpu and my fans go into overdrive just from having it open.

I also didnt have the error when I was using an older version of unity, but I’m stuck with this one since its what unityhub allows me to download and its too much of an hassle to downgrade and install android packages without unity hub.

So my question is, does anyone know if it is possible to fix this error without changing either software?

Here is the error, thanks!

ArgumentException: Value does not fall within the expected range.
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.LanguageOf (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit) (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder..ctor () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolutionFromAssetDatabase () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnPreGeneratingCSProjectFiles () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <fb001e01371b4adca20013e0ac763896>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <fb001e01371b4adca20013e0ac763896>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <fb001e01371b4adca20013e0ac763896>:0)
UnityEditor.AssetPostprocessingInternal.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles () (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.SyncVS.SyncVisualStudioProjectIfItAlreadyExists () (at <8004fcc221b54f98ba547350ea71d812>:0)

Inside your Unity project are some folders, such as:

Assets/
ProjectSettings/
Library/

and perhaps others.

Inside of that Library is a folder where built DLLs are stored:

Library/ScriptAssemblies/

Close Unity and then delete that ScriptAssemblies folder.

Now reopen Unity and all the C# files will be recompiled.

This may or may not fix your error.

Thanks kurt, I tried it but it did not fix it.

I figure the problem lies in this folder: Assets/UnityVS

6359367--707526--Untitled.png

it comes from the package visual studio tools for unity on C:\Program Files (x86)\Microsoft Visual Studio Tools for Unity\15.0

I figure theres some conflict between versions in the package

If this means anything to you please let me know, thanks!

Is that part of the VS integration package? maybe update taht? Or delete it and let it reinstall?

hmm actually deleting it had no effect, still popped the same error

however after reimporting the package(which I couldnt until i deleted the folder) i got an error that I already had the assemblies, even though I had them deleted( maybe there are copies somewhere else? )

PrecompiledAssemblyException: Multiple precompiled assemblies with the same name SyntaxTree.VisualStudio.Unity.Bridge.dll included or the current platform. Only one assembly with the same name is allowed per platform. Assembly paths:
C:/Program Files (x86)/Microsoft Visual Studio Tools for Unity/15.0/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll
Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll
UnityEditor.Scripting.ScriptCompilation.EditorBuildRules.ValidateAndGetNameToPrecompiledAssembly (UnityEditor.Scripting.ScriptCompilation.PrecompiledAssembly[] precompiledAssemblies) (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.Scripting.ScriptCompilation.EditorBuildRules.ToScriptAssemblies (System.Collections.Generic.IDictionary`2[TKey,TValue] targetAssemblies, UnityEditor.Scripting.ScriptCompilation.ScriptAssemblySettings settings, UnityEditor.Scripting.ScriptCompilation.EditorBuildRules+CompilationAssemblies assemblies, System.Collections.Generic.HashSet`1[T] runUpdaterAssemblies) (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.Scripting.ScriptCompilation.EditorBuildRules.GenerateChangedScriptAssemblies (UnityEditor.Scripting.ScriptCompilation.EditorBuildRules+GenerateChangedScriptAssembliesArgs args) (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CompileScripts (UnityEditor.Scripting.ScriptCompilation.ScriptAssemblySettings scriptAssemblySettings, System.String tempBuildDirectory, UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, UnityEditor.Scripting.ScriptCompilation.CompilationTaskOptions compilationTaskOptions, UnityEditor.Scripting.ScriptCompilation.EditorBuildRules+TargetAssembly[]& notCompiledTargetAssemblies, System.String[]& notCompiledScripts) (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CompileScripts (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, UnityEditor.BuildTargetGroup platformGroup, UnityEditor.BuildTarget platform, UnityEditor.Scripting.ScriptCompilation.CompilationTaskOptions compilationTaskOptions) (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, UnityEditor.BuildTargetGroup platformGroup, UnityEditor.BuildTarget platform) (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface.TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, UnityEditor.BuildTargetGroup platformGroup, UnityEditor.BuildTarget platform) (at <8004fcc221b54f98ba547350ea71d812>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget)

Well there are, somewhere in either Library or Packages or something. I don’t have anything in front of me to try and tell you, so keep fiddling, you’ll probably get it fixed…

i guess it is using the assembly directly from the path C:/Program Files (x86)/Microsoft Visual Studio Tools for Unity/15.0/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll ?

That’s why it would claim duplicate when importing

It seems that theres a problem itself with the .dlls

Updating them would mean updating to visual studio 2019 which I wanted to avoid… I can live with seeing the error everytime I boot the project rather than having to use 2019, maybe the tools from vs2019 work for vs2017? I don’t know at this point

I just deleted the unityVS folder from the project and the folder C:/Program Files (x86)/Microsoft Visual Studio Tools for Unity, and it is fixed now.

everything else seems to still work for now, so I guess that folder is not needed

1 Like