Search Unity

Error when booting project + when opening the first script

Discussion in 'Scripting' started by raarc, Sep 28, 2020.

  1. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    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!

    Code (CSharp):
    1. ArgumentException: Value does not fall within the expected range.
    2. SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.LanguageOf (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit) (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
    3. SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
    4. SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder..ctor () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
    5. SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolutionFromAssetDatabase () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
    6. SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
    7. SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnPreGeneratingCSProjectFiles () (at <46c1600e7cc74cd5bc97145420df9cc5>:0)
    8. 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)
    9. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    10. 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)
    11. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <fb001e01371b4adca20013e0ac763896>:0)
    12. UnityEditor.AssetPostprocessingInternal.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) (at <8004fcc221b54f98ba547350ea71d812>:0)
    13. UnityEditor.AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles () (at <8004fcc221b54f98ba547350ea71d812>:0)
    14. UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at <8004fcc221b54f98ba547350ea71d812>:0)
    15. UnityEditor.SyncVS.SyncVisualStudioProjectIfItAlreadyExists () (at <8004fcc221b54f98ba547350ea71d812>:0)
    16.  
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Inside your Unity project are some folders, such as:

    Code (csharp):
    1. Assets/
    2. ProjectSettings/
    3. Library/
    and perhaps others.

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

    Code (csharp):
    1. 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.
     
  3. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    Thanks kurt, I tried it but it did not fix it.

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

    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!
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Is that part of the VS integration package? maybe update taht? Or delete it and let it reinstall?
     
  5. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    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? )

    Code (CSharp):
    1. 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:
    2. C:/Program Files (x86)/Microsoft Visual Studio Tools for Unity/15.0/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll
    3. Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll
    4. UnityEditor.Scripting.ScriptCompilation.EditorBuildRules.ValidateAndGetNameToPrecompiledAssembly (UnityEditor.Scripting.ScriptCompilation.PrecompiledAssembly[] precompiledAssemblies) (at <8004fcc221b54f98ba547350ea71d812>:0)
    5. 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)
    6. UnityEditor.Scripting.ScriptCompilation.EditorBuildRules.GenerateChangedScriptAssemblies (UnityEditor.Scripting.ScriptCompilation.EditorBuildRules+GenerateChangedScriptAssembliesArgs args) (at <8004fcc221b54f98ba547350ea71d812>:0)
    7. 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)
    8. UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CompileScripts (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, UnityEditor.BuildTargetGroup platformGroup, UnityEditor.BuildTarget platform, UnityEditor.Scripting.ScriptCompilation.CompilationTaskOptions compilationTaskOptions) (at <8004fcc221b54f98ba547350ea71d812>:0)
    9. UnityEditor.Scripting.ScriptCompilation.EditorCompilation.TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, UnityEditor.BuildTargetGroup platformGroup, UnityEditor.BuildTarget platform) (at <8004fcc221b54f98ba547350ea71d812>:0)
    10. UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface.TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, UnityEditor.BuildTargetGroup platformGroup, UnityEditor.BuildTarget platform) (at <8004fcc221b54f98ba547350ea71d812>:0)
    11. UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget)
    12.  
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    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...
     
  7. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    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
     
  8. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    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