Unity2018 Open C# Project Error


錯誤日志

升級到Unity2018之后,使用 Open C# Project 打開VS工程,出現報錯,無法啟動VS。

錯誤日志如下:

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

在Unity的Download Assistant中進行下載VS組件

image

vs_Enterprise安裝Unity組件

在vs_Enterprise.exe 中安裝unity的組件也是失敗

image

image

其它排查方法

懷疑是Unity的問題,重新安裝 Unity,問題無法解決。

更換其它版本的unity,比如2018.2.9f1,問題無法解決。

解決方案

如果是VS2015,則可以通過下載新版本的Visual Studio Tools  For Unity 進行更新。(公司機器測試通過)

如果是VS2013,下載新版本的Visual Studio Tools  For Unity 更新后也是失敗(家里機器)。

更新VS2017,問題得到解決。

 

相關帖子:https://forum.unity.com/threads/error-with-unity-and-visual-studio-bridge-vs-project-not-updating-when-new-scripts-added.511761/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM