Unity2018: How to Solve C# Project Open Error

Error Log

After upgrading to Unity2018, opening VS project with Open C# Project, an error is reported and VS cannot be started.

The error logs are as follows.

ArgumentException: Value does not fall within the expected range.
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.LanguageOf (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit)
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits (System.String method)
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits ()
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder..ctor ()
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolutionFromAssetDatabase ()
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject ()
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnPreGeneratingCSProjectFiles ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles () (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:194)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:207)
UnityEditor.SyncVS.SyncSolution () (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:190)
UnityEditor.SyncVS.SyncAndOpenSolution () (at C:/buildslave/unity/build/Editor/Mono/SyncProje

Unity Down Assistant

To download VS components in Unity’s Download Assistant

vs_Enterprise to install Unity components

Installing unity’s components in vs_Enterprise.exe also fails

Other troubleshooting methods

Suspected Unity problem, reinstall Unity, the problem can’t be solved.

Replaced other versions of unity, e.g. 2018.2.9f1, problem not solved.

Solution

If it is VS2015, update it by downloading a new version of Visual Studio Tools For Unity. (Tested on company machine)

If it’s VS2013, downloading a new version of Visual Studio Tools For Unity to update also fails (home machine).

Update VS2017 and the problem is solved.

 

Similar Posts: